tpoechtrager / osxcross

Mac OS X cross toolchain for Linux, FreeBSD, OpenBSD and Android (Termux)
GNU General Public License v2.0
2.85k stars 320 forks source link

compiler-rt: Add option to automate install process #284

Closed akien-mga closed 3 years ago

akien-mga commented 3 years ago

Also mention that compiler-rt can be needed to build code using __builtin_available().

Fixes #278.

Note: Draft as I'm still testing it to see if it actually works as expected. Edit: Tested OK with USE_CMAKE=1 and LLVM 12 on Fedora 34.

akien-mga commented 3 years ago

Seems to work fine for the USE_CMAKE=1 variant:

Installing compiler-rt headers and libraries to the following paths:
  /usr/lib64/clang/12.0.0/include
  /usr/lib64/clang/12.0.0/lib/darwin

'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer' -> '/usr/lib64/clang/12.0.0/include/sanitizer'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/allocator_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/allocator_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/asan_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/asan_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/common_interface_defs.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/common_interface_defs.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/coverage_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/coverage_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/dfsan_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/dfsan_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/hwasan_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/hwasan_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/linux_syscall_hooks.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/linux_syscall_hooks.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/lsan_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/lsan_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/memprof_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/memprof_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/msan_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/msan_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/netbsd_syscall_hooks.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/netbsd_syscall_hooks.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/scudo_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/scudo_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/tsan_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/tsan_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/tsan_interface_atomic.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/tsan_interface_atomic.h'
'/root/osxcross/build/compiler-rt/compiler-rt/include/sanitizer/ubsan_interface.h' -> '/usr/lib64/clang/12.0.0/include/sanitizer/ubsan_interface.h'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.cc_kext.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.cc_kext.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.fuzzer_interceptors_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.fuzzer_interceptors_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.fuzzer_no_main_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.fuzzer_no_main_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.fuzzer_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.fuzzer_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.profile_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.profile_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.stats_client_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.stats_client_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.ubsan_minimal_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.ubsan_minimal_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.ubsan_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.ubsan_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.xray-basic_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.xray-basic_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.xray-fdr_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.xray-fdr_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.xray-profiling_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.xray-profiling_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.xray_osx.a' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.xray_osx.a'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.asan_osx_dynamic.dylib' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.asan_osx_dynamic.dylib'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.lsan_osx_dynamic.dylib'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.stats_osx_dynamic.dylib' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.stats_osx_dynamic.dylib'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.tsan_osx_dynamic.dylib'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.ubsan_minimal_osx_dynamic.dylib'
'/root/osxcross/build/compiler-rt/compiler-rt/build/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib' -> '/usr/lib64/clang/12.0.0/lib/darwin/libclang_rt.ubsan_osx_dynamic.dylib'

I don't have an old enough llvm to compile against to test the USE_CMAKE=0 case.

tpoechtrager commented 3 years ago

Thank you. This is a great addition. The only concern I have is it usually requires root to install the libraries and headers. But since it's still optional it's fine.

akien-mga commented 3 years ago

Indeed, one could optionally add a check at the start of the script to error out if the option is used and the user is not root or sudo.