[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
This revision was landed with ongoing or failed builds. This revision was automatically updated to reflect the committed changes. Closed by commit rGa44477b1f4b5: [CompilerRT] Remove ubsan static runtime on Apple (authored by usama54321). Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141550/new/ https://reviews.llvm.org/D141550 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/sanitizer-ld.c compiler-rt/lib/ubsan/CMakeLists.txt compiler-rt/test/ubsan/CMakeLists.txt Index: compiler-rt/test/ubsan/CMakeLists.txt === --- compiler-rt/test/ubsan/CMakeLists.txt +++ compiler-rt/test/ubsan/CMakeLists.txt @@ -101,7 +101,6 @@ set(UBSAN_TEST_TARGET_ARCH ${arch}) get_test_cc_for_arch(${arch} UBSAN_TEST_TARGET_CC UBSAN_TEST_TARGET_CFLAGS) set(UBSAN_TEST_TARGET_CFLAGS "${UBSAN_TEST_TARGET_CFLAGS} -lc++abi") -add_ubsan_testsuites("StandaloneStatic" ubsan ${arch}) endforeach() # Device and simulator test suites. Index: compiler-rt/lib/ubsan/CMakeLists.txt === --- compiler-rt/lib/ubsan/CMakeLists.txt +++ compiler-rt/lib/ubsan/CMakeLists.txt @@ -114,19 +114,21 @@ LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET ubsan) -add_compiler_rt_runtime(clang_rt.ubsan - STATIC - OS ${UBSAN_SUPPORTED_OS} - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan - RTUbsan_standalone - RTSanitizerCommonNoHooks - RTSanitizerCommonLibcNoHooks - RTSanitizerCommonCoverage - RTSanitizerCommonSymbolizerNoHooks - RTInterception - LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} - PARENT_TARGET ubsan) +if (NOT APPLE) + add_compiler_rt_runtime(clang_rt.ubsan +STATIC +OS ${UBSAN_SUPPORTED_OS} +ARCHS ${UBSAN_SUPPORTED_ARCH} +OBJECT_LIBS RTUbsan +RTUbsan_standalone +RTSanitizerCommonNoHooks +RTSanitizerCommonLibcNoHooks +RTSanitizerCommonCoverage +RTSanitizerCommonSymbolizerNoHooks +RTInterception +LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} +PARENT_TARGET ubsan) +endif() endif() else() Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -423,8 +423,7 @@ // RUN: --target=x86_64-apple-darwin -fuse-ld=ld -static-libsan \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-UBSAN-STATIC-DARWIN %s -// CHECK-UBSAN-STATIC-DARWIN: "{{.*}}ld{{(.exe)?}}" -// CHECK-UBSAN-STATIC-DARWIN: "{{.*}}libclang_rt.ubsan_osx.a" +// CHECK-UBSAN-STATIC-DARWIN: {{.*}}error: static UndefinedBehaviorSanitizer runtime is not supported on darwin // RUN: %clang -fsanitize=address,undefined -### %s 2>&1 \ // RUN: --target=i386-unknown-linux -fuse-ld=ld \ Index: clang/lib/Driver/ToolChains/Darwin.cpp === --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -1425,15 +1425,22 @@ } const SanitizerArgs = getSanitizerArgs(Args); + + if (!Sanitize.needsSharedRt() && Sanitize.needsUbsanRt()) { +getDriver().Diag(diag::err_drv_unsupported_static_ubsan_darwin); +return; + } + if (Sanitize.needsAsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "asan"); if (Sanitize.needsLsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan"); - if (Sanitize.needsUbsanRt()) + if (Sanitize.needsUbsanRt()) { +assert(Sanitize.needsSharedRt() && "Static sanitizer runtimes not supported"); AddLinkSanitizerLibArgs(Args, CmdArgs, Sanitize.requiresMinimalRuntime() ? "ubsan_minimal" - : "ubsan", -Sanitize.needsSharedRt()); + : "ubsan"); + } if (Sanitize.needsTsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan"); if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) { Index: clang/include/clang/Basic/DiagnosticDriverKinds.td === --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -215,6 +215,8 @@ "malformed sanitizer coverage allowlist: '%0'">; def err_drv_malformed_sanitizer_coverage_ignorelist : Error< "malformed sanitizer coverage ignorelist: '%0'">; +def err_drv_unsupported_static_ubsan_darwin : Error< + "static UndefinedBehaviorSanitizer runtime is not
[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
thetruestblue accepted this revision. thetruestblue added a comment. This seems reasonable to me. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141550/new/ https://reviews.llvm.org/D141550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
delcypher accepted this revision. delcypher added a comment. This revision is now accepted and ready to land. LGTM Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141550/new/ https://reviews.llvm.org/D141550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
delcypher added inline comments. Comment at: compiler-rt/lib/ubsan/CMakeLists.txt:118 +if (NOT APPLE) + add_compiler_rt_runtime(clang_rt.ubsan +STATIC usama54321 wrote: > delcypher wrote: > > I think you may have accidentally added tabs here when re-indenting. > I double checked and these are spaces :/ Oh my bad. Maybe the `>>` symbol in phrabricator means indent rather than a particular space/tab choice. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141550/new/ https://reviews.llvm.org/D141550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
usama54321 marked an inline comment as done. usama54321 added inline comments. Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:219 +def err_drv_unsupported_static_ubsan_darwin : Error< + "Static UBSan runtime is not supported on darwin">; def err_drv_duplicate_config : Error< delcypher wrote: > Nit: Driver messages start with lowercase. > > Also please check if "UBSan" is spelt differently in existing driver > messages. It might actually be written more explicitly like "undefined > behavior sanitizer". renamed UBSan to UndefinedBehaviorSanitizer as I see instances of AddressSanitizer and ThreadSanitizer in other messages. Did not find an equivalent for ubsan Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141550/new/ https://reviews.llvm.org/D141550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
usama54321 marked 3 inline comments as done. usama54321 added inline comments. Comment at: compiler-rt/lib/ubsan/CMakeLists.txt:118 +if (NOT APPLE) + add_compiler_rt_runtime(clang_rt.ubsan +STATIC delcypher wrote: > I think you may have accidentally added tabs here when re-indenting. I double checked and these are spaces :/ Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141550/new/ https://reviews.llvm.org/D141550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
usama54321 updated this revision to Diff 488408. usama54321 added a comment. Addressing comments Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141550/new/ https://reviews.llvm.org/D141550 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/sanitizer-ld.c compiler-rt/lib/ubsan/CMakeLists.txt compiler-rt/test/ubsan/CMakeLists.txt Index: compiler-rt/test/ubsan/CMakeLists.txt === --- compiler-rt/test/ubsan/CMakeLists.txt +++ compiler-rt/test/ubsan/CMakeLists.txt @@ -101,7 +101,6 @@ set(UBSAN_TEST_TARGET_ARCH ${arch}) get_test_cc_for_arch(${arch} UBSAN_TEST_TARGET_CC UBSAN_TEST_TARGET_CFLAGS) set(UBSAN_TEST_TARGET_CFLAGS "${UBSAN_TEST_TARGET_CFLAGS} -lc++abi") -add_ubsan_testsuites("StandaloneStatic" ubsan ${arch}) endforeach() # Device and simulator test suites. Index: compiler-rt/lib/ubsan/CMakeLists.txt === --- compiler-rt/lib/ubsan/CMakeLists.txt +++ compiler-rt/lib/ubsan/CMakeLists.txt @@ -114,19 +114,21 @@ LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET ubsan) -add_compiler_rt_runtime(clang_rt.ubsan - STATIC - OS ${UBSAN_SUPPORTED_OS} - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan - RTUbsan_standalone - RTSanitizerCommonNoHooks - RTSanitizerCommonLibcNoHooks - RTSanitizerCommonCoverage - RTSanitizerCommonSymbolizerNoHooks - RTInterception - LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} - PARENT_TARGET ubsan) +if (NOT APPLE) + add_compiler_rt_runtime(clang_rt.ubsan +STATIC +OS ${UBSAN_SUPPORTED_OS} +ARCHS ${UBSAN_SUPPORTED_ARCH} +OBJECT_LIBS RTUbsan +RTUbsan_standalone +RTSanitizerCommonNoHooks +RTSanitizerCommonLibcNoHooks +RTSanitizerCommonCoverage +RTSanitizerCommonSymbolizerNoHooks +RTInterception +LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} +PARENT_TARGET ubsan) +endif() endif() else() Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -423,8 +423,7 @@ // RUN: --target=x86_64-apple-darwin -fuse-ld=ld -static-libsan \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-UBSAN-STATIC-DARWIN %s -// CHECK-UBSAN-STATIC-DARWIN: "{{.*}}ld{{(.exe)?}}" -// CHECK-UBSAN-STATIC-DARWIN: "{{.*}}libclang_rt.ubsan_osx.a" +// CHECK-UBSAN-STATIC-DARWIN: {{.*}}error: static UndefinedBehaviorSanitizer runtime is not supported on darwin // RUN: %clang -fsanitize=address,undefined -### %s 2>&1 \ // RUN: --target=i386-unknown-linux -fuse-ld=ld \ Index: clang/lib/Driver/ToolChains/Darwin.cpp === --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -1425,15 +1425,22 @@ } const SanitizerArgs = getSanitizerArgs(Args); + + if (!Sanitize.needsSharedRt() && Sanitize.needsUbsanRt()) { +getDriver().Diag(diag::err_drv_unsupported_static_ubsan_darwin); +return; + } + if (Sanitize.needsAsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "asan"); if (Sanitize.needsLsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "lsan"); - if (Sanitize.needsUbsanRt()) + if (Sanitize.needsUbsanRt()) { +assert(Sanitize.needsSharedRt() && "Static sanitizer runtimes not supported"); AddLinkSanitizerLibArgs(Args, CmdArgs, Sanitize.requiresMinimalRuntime() ? "ubsan_minimal" - : "ubsan", -Sanitize.needsSharedRt()); + : "ubsan"); + } if (Sanitize.needsTsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan"); if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) { Index: clang/include/clang/Basic/DiagnosticDriverKinds.td === --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -215,6 +215,8 @@ "malformed sanitizer coverage allowlist: '%0'">; def err_drv_malformed_sanitizer_coverage_ignorelist : Error< "malformed sanitizer coverage ignorelist: '%0'">; +def err_drv_unsupported_static_ubsan_darwin : Error< + "static UndefinedBehaviorSanitizer runtime is not supported on darwin">; def err_drv_duplicate_config : Error< "no more than one option '--config' is allowed">; def
[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
delcypher added a comment. Overall approach LGTM. I just have some very minor nits. Comment at: clang/include/clang/Basic/DiagnosticDriverKinds.td:219 +def err_drv_unsupported_static_ubsan_darwin : Error< + "Static UBSan runtime is not supported on darwin">; def err_drv_duplicate_config : Error< Nit: Driver messages start with lowercase. Also please check if "UBSan" is spelt differently in existing driver messages. It might actually be written more explicitly like "undefined behavior sanitizer". Comment at: clang/lib/Driver/ToolChains/Darwin.cpp:1441 Sanitize.requiresMinimalRuntime() ? "ubsan_minimal" - : "ubsan", -Sanitize.needsSharedRt()); + : "ubsan"); if (Sanitize.needsTsanRt()) Maybe add an assert? As the code is constructed right now it should never fail but in the future someone could change the code and break the assumption. ```lang=c++ if (Sanitize.needsUbsanRt()) { assert(Sanitize.needsSharedRt() && "Static sanitizer runtimes not supported"); AddLinkSanitizerLibArgs(Args, CmdArgs, Sanitize.requiresMinimalRuntime() ? "ubsan_minimal" : "ubsan"); } ``` Comment at: compiler-rt/lib/ubsan/CMakeLists.txt:118 +if (NOT APPLE) + add_compiler_rt_runtime(clang_rt.ubsan +STATIC I think you may have accidentally added tabs here when re-indenting. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D141550/new/ https://reviews.llvm.org/D141550 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D141550: [CompilerRT] Remove ubsan static runtime on Apple
usama54321 created this revision. Herald added a subscriber: Enna1. Herald added a project: All. usama54321 requested review of this revision. Herald added subscribers: Sanitizers, cfe-commits, MaskRay. Herald added projects: clang, Sanitizers. This patch removes the static ubsan runtime on Apple devices. The motivation is to reduce the toolchain size. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D141550 Files: clang/include/clang/Basic/DiagnosticDriverKinds.td clang/lib/Driver/ToolChains/Darwin.cpp clang/test/Driver/sanitizer-ld.c compiler-rt/lib/ubsan/CMakeLists.txt compiler-rt/test/ubsan/CMakeLists.txt Index: compiler-rt/test/ubsan/CMakeLists.txt === --- compiler-rt/test/ubsan/CMakeLists.txt +++ compiler-rt/test/ubsan/CMakeLists.txt @@ -101,7 +101,6 @@ set(UBSAN_TEST_TARGET_ARCH ${arch}) get_test_cc_for_arch(${arch} UBSAN_TEST_TARGET_CC UBSAN_TEST_TARGET_CFLAGS) set(UBSAN_TEST_TARGET_CFLAGS "${UBSAN_TEST_TARGET_CFLAGS} -lc++abi") -add_ubsan_testsuites("StandaloneStatic" ubsan ${arch}) endforeach() # Device and simulator test suites. Index: compiler-rt/lib/ubsan/CMakeLists.txt === --- compiler-rt/lib/ubsan/CMakeLists.txt +++ compiler-rt/lib/ubsan/CMakeLists.txt @@ -114,19 +114,21 @@ LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} PARENT_TARGET ubsan) -add_compiler_rt_runtime(clang_rt.ubsan - STATIC - OS ${UBSAN_SUPPORTED_OS} - ARCHS ${UBSAN_SUPPORTED_ARCH} - OBJECT_LIBS RTUbsan - RTUbsan_standalone - RTSanitizerCommonNoHooks - RTSanitizerCommonLibcNoHooks - RTSanitizerCommonCoverage - RTSanitizerCommonSymbolizerNoHooks - RTInterception - LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} - PARENT_TARGET ubsan) +if (NOT APPLE) + add_compiler_rt_runtime(clang_rt.ubsan +STATIC +OS ${UBSAN_SUPPORTED_OS} +ARCHS ${UBSAN_SUPPORTED_ARCH} +OBJECT_LIBS RTUbsan +RTUbsan_standalone +RTSanitizerCommonNoHooks +RTSanitizerCommonLibcNoHooks +RTSanitizerCommonCoverage +RTSanitizerCommonSymbolizerNoHooks +RTInterception +LINK_FLAGS ${WEAK_SYMBOL_LINK_FLAGS} +PARENT_TARGET ubsan) +endif() endif() else() Index: clang/test/Driver/sanitizer-ld.c === --- clang/test/Driver/sanitizer-ld.c +++ clang/test/Driver/sanitizer-ld.c @@ -423,8 +423,7 @@ // RUN: --target=x86_64-apple-darwin -fuse-ld=ld -static-libsan \ // RUN: --sysroot=%S/Inputs/basic_linux_tree \ // RUN: | FileCheck --check-prefix=CHECK-UBSAN-STATIC-DARWIN %s -// CHECK-UBSAN-STATIC-DARWIN: "{{.*}}ld{{(.exe)?}}" -// CHECK-UBSAN-STATIC-DARWIN: "{{.*}}libclang_rt.ubsan_osx.a" +// CHECK-UBSAN-STATIC-DARWIN: {{.*}}error: Static UBSan runtime is not supported on darwin // RUN: %clang -fsanitize=address,undefined -### %s 2>&1 \ // RUN: --target=i386-unknown-linux -fuse-ld=ld \ Index: clang/lib/Driver/ToolChains/Darwin.cpp === --- clang/lib/Driver/ToolChains/Darwin.cpp +++ clang/lib/Driver/ToolChains/Darwin.cpp @@ -1425,6 +1425,12 @@ } const SanitizerArgs = getSanitizerArgs(Args); + + if (!Sanitize.needsSharedRt() && Sanitize.needsUbsanRt()) { +getDriver().Diag(diag::err_drv_unsupported_static_ubsan_darwin); +return; + } + if (Sanitize.needsAsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "asan"); if (Sanitize.needsLsanRt()) @@ -1432,8 +1438,7 @@ if (Sanitize.needsUbsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, Sanitize.requiresMinimalRuntime() ? "ubsan_minimal" - : "ubsan", -Sanitize.needsSharedRt()); + : "ubsan"); if (Sanitize.needsTsanRt()) AddLinkSanitizerLibArgs(Args, CmdArgs, "tsan"); if (Sanitize.needsFuzzer() && !Args.hasArg(options::OPT_dynamiclib)) { Index: clang/include/clang/Basic/DiagnosticDriverKinds.td === --- clang/include/clang/Basic/DiagnosticDriverKinds.td +++ clang/include/clang/Basic/DiagnosticDriverKinds.td @@ -215,6 +215,8 @@ "malformed sanitizer coverage allowlist: '%0'">; def err_drv_malformed_sanitizer_coverage_ignorelist : Error< "malformed sanitizer coverage ignorelist: '%0'">; +def err_drv_unsupported_static_ubsan_darwin : Error< + "Static UBSan runtime is not supported on darwin">; def err_drv_duplicate_config : Error< "no more than one option '--config' is allowed">; def err_drv_cannot_open_config_file :