Skip to content

Conversation

@reckenrode
Copy link
Contributor

@reckenrode reckenrode commented Aug 4, 2023

Description of changes

This fixes two issues on Darwin to allow pkgsStatic to work with LLVM 16

  • It fixes an infinite recursion where Darwin was using a regular stdenv to build compiler-rt instead of one without compiler-rt; and
  • It disables sanitizers that won’t build statically and makes sure the build can find the cross-lipo.

This should fix the evaluation error blocking #241692.

Testing was done by cherry-picking #241692 and running nix build .#pkgsStatic.hello on an aarch64-darwin machine.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.11 Release Notes (or backporting 23.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

@reckenrode reckenrode changed the title llvmPackages_{12-16}: fix evaluation failure of pkgsStatic on Darwin llvmPackages_16.compiler-rt: fix static build on Darwin Aug 4, 2023
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Aug 4, 2023
@ofborg ofborg bot added 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. labels Aug 4, 2023
Copy link
Contributor

@tjni tjni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thank you!

@figsoda figsoda added the 12.approvals: 1 This PR was reviewed and approved by one person. label Aug 9, 2023
@tjni
Copy link
Contributor

tjni commented Aug 21, 2023

Just want to call attention to CI reporting the following failure:

> [531/677] Building CXX object lib/interception/CMakeFiles/RTInterception.osx.dir/interception_type_test.cpp.o
> [532/677] Building CXX object lib/stats/CMakeFiles/clang_rt.stats_osx_dynamic.dir/stats.cpp.o
> [533/677] Linking CXX shared library lib/darwin/libclang_rt.stats_osx_dynamic.dylib
> FAILED: lib/darwin/libclang_rt.stats_osx_dynamic.dylib
> : && /nix/store/nf88qx6vd8plhvb4ldwqsajik6c42wbj-clang-wrapper-16.0.6/bin/clang++ -Wall -Wno-unused-parameter -O3 -DNDEBUG -arch x86_64 -dynamiclib -Wl,-headerpad_max_install_names -stdlib=libc++ -lc++ -lc++abi -fapplication-extension -mmacosx-version-min=10.10 -isysroot /nix/store/v302y65qc8gyxqc49zv6gr08klvr6lg5-SDKs/MacOSX10.12.sdk -nodefaultlibs -nostdlib++ -Wl,-U,___asan_default_options -Wl,-U,___asan_default_suppressions -Wl,-U,___asan_on_error -Wl,-U,___asan_set_shadow_00 -Wl,-U,___asan_set_shadow_01 -Wl,-U,___asan_set_shadow_02 -Wl,-U,___asan_set_shadow_03 -Wl,-U,___asan_set_shadow_04 -Wl,-U,___asan_set_shadow_05 -Wl,-U,___asan_set_shadow_06 -Wl,-U,___asan_set_shadow_07 -Wl,-U,___asan_set_shadow_f1 -Wl,-U,___asan_set_shadow_f2 -Wl,-U,___asan_set_shadow_f3 -Wl,-U,___asan_set_shadow_f4 -Wl,-U,___asan_set_shadow_f5 -Wl,-U,___asan_set_shadow_f6 -Wl,-U,___asan_set_shadow_f7 -Wl,-U,___asan_set_shadow_f8 -Wl,-U,___ubsan_default_options -Wl,-U,___sanitizer_free_hook -Wl,-U,___sanitizer_malloc_hook -Wl,-U,___sanitizer_report_error_summary -Wl,-U,___sanitizer_sandbox_on_notify -Wl,-U,___sanitizer_symbolize_code -Wl,-U,___sanitizer_symbolize_data -Wl,-U,___sanitizer_symbolize_demangle -Wl,-U,___sanitizer_symbolize_flush -Wl,-U,___sanitizer_symbolize_set_demangle -Wl,-U,___sanitizer_symbolize_set_inline_frames -o lib/darwin/libclang_rt.stats_osx_dynamic.dylib -install_name @rpath/libclang_rt.stats_osx_dynamic.dylib lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_allocator.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_common.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_deadlock_detector1.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_deadlock_detector2.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_errno.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_file.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_flags.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_flag_parser.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_fuchsia.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_libc.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_libignore.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_linux.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_linux_s390.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_mac.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_mutex.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_netbsd.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_freebsd.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_linux.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_netbsd.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_posix.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_platform_limits_solaris.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_posix.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_printf.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_common.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_bsd.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_fuchsia.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_linux.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_mac.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_procmaps_solaris.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_solaris.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stoptheworld_fuchsia.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stoptheworld_mac.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_stoptheworld_win.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_suppressions.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_tls_get_addr.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_thread_registry.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_type_traits.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_win.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommon.osx.dir/sanitizer_termination.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_common_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_allocator_checks.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_linux_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_mac_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_posix_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_stoptheworld_linux_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonLibc.osx.dir/sanitizer_stoptheworld_netbsd_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_allocator_report.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_chained_origin_depot.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stack_store.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stackdepot.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stacktrace.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stacktrace_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stacktrace_printer.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_stacktrace_sparc.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_libbacktrace.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_mac.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_markup.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_posix_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_report.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_symbolizer_win.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_unwind_linux_libcdep.cpp.o lib/sanitizer_common/CMakeFiles/RTSanitizerCommonSymbolizer.osx.dir/sanitizer_unwind_win.cpp.o lib/stats/CMakeFiles/clang_rt.stats_osx_dynamic.dir/stats.cpp.o  -lc && :
> clang-16: warning: argument unused during compilation: '-stdlib=libc++' [-Wunused-command-line-argument]
> ld: library not found for -lc++
> clang-16: error: linker command failed with exit code 1 (use -v to see invocation)
> ninja: build stopped: subcommand failed.
For full logs, run 'nix log /nix/store/h577p2y0mhby8fkjdv57i6sf2gq1vpjr-compiler-rt-libc-16.0.6.drv'.

@reckenrode
Copy link
Contributor Author

Just want to call attention to CI reporting the following failure:

Thanks for the head up. I’ll look into it Monday evening.

@reckenrode
Copy link
Contributor Author

My guess is it’s failing without the clang 16 stdenv. I probably need to copy whatever logic I’m using there to make sure the sanitizers can still build.

@reckenrode reckenrode force-pushed the compiler-rt-static branch 2 times, most recently from c3c5320 to 87e85b3 Compare August 22, 2023 01:16
@reckenrode
Copy link
Contributor Author

reckenrode commented Aug 22, 2023

I simplified the patch. I confirmed that pkgsStatic.hello builds with the clang 16 stdenv and llvmPackages_16.compiler-rt builds with both the clang 11 and clang 16 stdenvs.

This fixes two issues on Darwin to allow pkgsStatic to work with LLVM 16

* It fixes an infinite recursion where Darwin was using a regular stdenv
  to build compiler-rt instead of one without compiler-rt; and
* It disables sanitizers that won’t build statically and makes sure the
  build can find the cross-lipo.
@reckenrode
Copy link
Contributor Author

As a follow up once this is merged, I can port this to llvmPackages_git and possibly the other ones (12–15) as well for consistency. I don’t want the scope of this one to creep up since it is blocking #241692.

@tjni tjni merged commit 174e4f4 into NixOS:master Aug 22, 2023
@reckenrode reckenrode deleted the compiler-rt-static branch August 22, 2023 04:47
@rrbutani rrbutani added the 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related label May 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: darwin Running or building packages on Darwin 6.topic: llvm/clang Issues related to llvmPackages, clangStdenv and related 10.rebuild-darwin: 11-100 This PR causes between 11 and 100 packages to rebuild on Darwin. 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux. 12.approvals: 1 This PR was reviewed and approved by one person.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants