This is an archive of the discontinued LLVM Phabricator instance.

[compiler-rt] Fix multi-configuration output paths
ClosedPublic

Authored by etienneb on May 13 2016, 3:01 PM.

Details

Summary

When using a multi-configuration build (i.e. MSVC) the output path where
libraries are dropped is incorrect.

Example:

C:\src\llvm\examples>d:\src\llvm\build\Release\bin\clang-cl.exe -fsanitize=address test.cc
LINK : fatal error LNK1181: cannot open input file 'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\clang_rt.asan-i386.lib'

The dropped executable path contains the configuration 'Release':

'd:\src\llvm\build\Release\bin\..\lib\clang\3.9.0\lib\windows\Release\clang_rt.asan-i386.lib'

The variable 'RUNTIME_OUTPUT_DIRECTORY' is used to specify the output directory.
But CMAKE is appending the current configuration (i.e. Debug, Release).

see: https://cmake.org/cmake/help/v3.0/prop_tgt/RUNTIME_OUTPUT_DIRECTORY.html

"Multi-configuration generators (VS, Xcode) append a per-configuration subdirectory to the specified directory."

To avoid this problem, the configuration specific variable must be set:
'RUNTIME_OUTPUT_DIRECTORY_DEBUG', 'RUNTIME_OUTPUT_DIRECTORY_RELEASE', and so on.

Diff Detail

Event Timeline

etienneb updated this revision to Diff 57261.May 13 2016, 3:01 PM
etienneb retitled this revision from to [compiler-rt] Fix multi-configuration output paths.
etienneb updated this object.
etienneb added a reviewer: rnk.
etienneb added a subscriber: cfe-commits.
etienneb updated this object.May 13 2016, 3:02 PM
rnk added a reviewer: chapuni.May 13 2016, 3:37 PM
rnk edited edge metadata.May 13 2016, 3:50 PM

Will this put the libraries in build/Release/bin/../lib/..... aka build/Release/lib, or will they collide between build types?

In D20261#430151, @rnk wrote:

Will this put the libraries in build/Release/bin/../lib/..... aka build/Release/lib, or will they collide between build types?

If I get your question correctly, they won't collide since the first folder below build is the configuration (a.k.a Debug/Release).

Before the patch, this is the output directory:

build/Release/lib/clang/3.9.0/lib/windows/Release

The value in MSVC is:

C:\src\llvm\build\$(Configuration)\lib\clang\3.9.0\lib\windows\Release\

The last Release folder is redundant.

After applying this patch, the MSVC value is:

C:\src\llvm\build\$(Configuration)\lib\clang\3.9.0\lib\windows\

Library files are produced in this folder:

build/Release/lib/clang/3.9.0/lib/windows
rnk accepted this revision.May 13 2016, 10:48 PM
rnk edited edge metadata.

Great! Lgtm

This revision is now accepted and ready to land.May 13 2016, 10:48 PM
etienneb edited edge metadata.May 15 2016, 12:39 PM
etienneb edited subscribers, added: llvm-commits; removed: cfe-commits.
etienneb updated this revision to Diff 57310.May 15 2016, 4:39 PM

fix more cases

etienneb updated this revision to Diff 57311.May 15 2016, 4:51 PM

nits: indent

etienneb updated this revision to Diff 57312.May 15 2016, 5:11 PM

fix sanitizer_common paths

I've fixed a few other cases to obtain a full working compilation with Visual Studio (multi-configuration).

The temporary files produced by the custom rules (clang_compile) do not contain the configuration (Debug/Release). To avoid names collision between configurations, this patch is adding the configuration to the path of the produced object files.

$ find . -name "*.o"
./compiler-rt/lib/asan/tests/Release/ASAN_BENCHMARKS_OBJECTS.asan_benchmarks_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_BENCHMARKS_OBJECTS.asan_benchmarks_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_BENCHMARKS_OBJECTS.gtest-all.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_BENCHMARKS_OBJECTS.gtest-all.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_asm_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_asm_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_globals_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_globals_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_interface_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_interface_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_mem_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_mem_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_oob_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_oob_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_str_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_str_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_test_main.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.asan_test_main.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.gtest-all.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_INST_TEST_OBJECTS.gtest-all.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_NOINST_TEST_OBJECTS.asan_fake_stack_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_NOINST_TEST_OBJECTS.asan_fake_stack_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_NOINST_TEST_OBJECTS.asan_noinst_test.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_NOINST_TEST_OBJECTS.asan_noinst_test.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_NOINST_TEST_OBJECTS.asan_test_main.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_NOINST_TEST_OBJECTS.asan_test_main.cc.i386-with-calls.o
./compiler-rt/lib/asan/tests/Release/ASAN_NOINST_TEST_OBJECTS.gtest-all.cc.i386-inline.o
./compiler-rt/lib/asan/tests/Release/ASAN_NOINST_TEST_OBJECTS.gtest-all.cc.i386-with-calls.o
./compiler-rt/lib/sanitizer_common/tests/Release/gtest-all.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_allocator_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_atomic_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_bitvector_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_bvgraph_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_common_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_deadlock_detector_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_flags_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_format_interceptor_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_ioctl_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_libc_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_linux_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_list_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_mutex_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_nolibc_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_posix_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_printf_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_procmaps_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_stackdepot_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_stacktrace_printer_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_stacktrace_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_stoptheworld_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_suppressions_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_symbolizer_test.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_test_main.cc.i386.o
./compiler-rt/lib/sanitizer_common/tests/Release/sanitizer_thread_registry_test.cc.i386.o

The same problem was happening with the libraries:

$ find . -name "*.lib"
./compiler-rt/lib/asan/RTAsan.i386.dir/Release/RTAsan.i386.lib
./compiler-rt/lib/asan/RTAsan_cxx.i386.dir/Release/RTAsan_cxx.i386.lib
./compiler-rt/lib/asan/RTAsan_dynamic.i386.dir/Release/RTAsan_dynamic.i386.lib
./compiler-rt/lib/asan/RTAsan_dynamic_version_script_dummy.i386.dir/Release/RTAsan_dynamic_version_script_dummy.i386.lib
./compiler-rt/lib/asan/RTAsan_preinit.i386.dir/Release/RTAsan_preinit.i386.lib
./compiler-rt/lib/asan/tests/default/Release/Asan-i386-inline-Benchmark.lib
./compiler-rt/lib/asan/tests/default/Release/Asan-i386-inline-Noinst-Test.lib
./compiler-rt/lib/asan/tests/default/Release/Asan-i386-inline-Test.lib
./compiler-rt/lib/asan/tests/default/Release/Asan-i386-with-calls-Benchmark.lib
./compiler-rt/lib/asan/tests/default/Release/Asan-i386-with-calls-Noinst-Test.lib
./compiler-rt/lib/asan/tests/default/Release/Asan-i386-with-calls-Test.lib
./compiler-rt/lib/asan/tests/dynamic/Release/Asan-i386-inline-Dynamic-Test.lib
./compiler-rt/lib/asan/tests/dynamic/Release/Asan-i386-with-calls-Dynamic-Test.lib
./compiler-rt/lib/asan/tests/Release/RTAsanTest.i386-inline.lib
./compiler-rt/lib/asan/tests/Release/RTAsanTest.i386-with-calls.lib
./compiler-rt/lib/interception/RTInterception.i386.dir/Release/RTInterception.i386.lib
./compiler-rt/lib/lsan/RTLSanCommon.i386.dir/Release/RTLSanCommon.i386.lib
./compiler-rt/lib/sanitizer_common/RTSanitizerCommon.i386.dir/Release/RTSanitizerCommon.i386.lib
./compiler-rt/lib/sanitizer_common/RTSanitizerCommonLibc.i386.dir/Release/RTSanitizerCommonLibc.i386.lib
./compiler-rt/lib/sanitizer_common/RTSanitizerCommonNoLibc.i386.dir/Release/RTSanitizerCommonNoLibc.i386.lib
./compiler-rt/lib/sanitizer_common/tests/Release/RTSanitizerCommon.test.i386.lib
./compiler-rt/lib/sanitizer_common/tests/Release/Sanitizer-i386-Test.lib
./compiler-rt/lib/ubsan/RTUbsan.i386.dir/Release/RTUbsan.i386.lib
./compiler-rt/lib/ubsan/RTUbsan_cxx.i386.dir/Release/RTUbsan_cxx.i386.lib
./compiler-rt/lib/ubsan/RTUbsan_standalone.i386.dir/Release/RTUbsan_standalone.i386.lib

Can someone confirm if this patch will affect clang buildbots?

This patch is supposed to affect only multi-configuration builds.
Do we run bots with multi-configuration generated files?

rnk added a comment.May 16 2016, 7:55 AM

We don't have any buildbots that test multi config sanitizers, they all use ninja now.

Lgtm

etienneb closed this revision.May 16 2016, 8:04 AM