xpack-dev-tools / clang-xpack

A binary distribution of the LLVM clang compiler infrastructure
https://xpack-dev-tools.github.io/clang-xpack/
MIT License
11 stars 2 forks source link

The macOS archives do not include all compiler-rt libraries #8

Closed ilg-ul closed 1 year ago

ilg-ul commented 1 year ago

Using 15.0.7-1 to compile a dynamic library during the Python build failed with a missing library (libclang_rt.profile_osx.a):

/Users/ilg/Work/meson-build-xpack.git/build/darwin-x64/xpacks/.bin/clang 
-dynamiclib 
-Wl,-single_module 
-L/Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib  
-O2 -v 
-Wl,-macosx_version_min,10.13 
-Wl,-headerpad_max_install_names 
-Wl,-dead_strip 
-Wl,-rpath,/Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib 
-L/Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib  
-O2 -v 
-Wl,-macosx_version_min,10.13 
-Wl,-headerpad_max_install_names 
-Wl,-dead_strip 
-Wl,-rpath,/Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib 
-flto 
-Wl,-export_dynamic -g -fprofile-instr-generate -undefined dynamic_lookup 
-Wl,-install_name,/Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib/libpython3.10.dylib 
-Wl,-compatibility_version,3.10 
-Wl,-current_version,3.10 
-o libpython3.10.dylib 
Modules/getbuildinfo.o Parser/token.o  Parser/pegen.o Parser/parser.o Parser/string_parser.o Parser/peg_api.o Parser/myreadline.o Parser/tokenizer.o Objects/abstract.o Objects/accu.o Objects/boolobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/bytesobject.o Objects/call.o Objects/capsule.o Objects/cellobject.o Objects/classobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genericaliasobject.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/interpreteridobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/odictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/namespaceobject.o Objects/object.o Objects/obmalloc.o Objects/picklebufobject.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/unicodeobject.o Objects/unicodectype.o Objects/unionobject.o Objects/weakrefobject.o Python/_warnings.o Python/Python-ast.o Python/asdl.o Python/ast.o Python/ast_opt.o Python/ast_unparse.o Python/bltinmodule.o Python/ceval.o Python/codecs.o Python/compile.o Python/context.o Python/dynamic_annotations.o Python/errors.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/hamt.o Python/hashtable.o Python/import.o Python/importdl.o Python/initconfig.o Python/marshal.o Python/modsupport.o Python/mysnprintf.o Python/mystrtoul.o Python/pathconfig.o Python/preconfig.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pyhash.o Python/pylifecycle.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/pytime.o Python/bootstrap_hash.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/thread.o Python/traceback.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/pystrhex.o Python/dtoa.o Python/formatter_unicode.o Python/fileutils.o Python/suggestions.o Python/dynload_shlib.o    Modules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o Modules/posixmodule.o  Modules/errnomodule.o  Modules/pwdmodule.o  Modules/_sre.o  Modules/_codecsmodule.o  Modules/_weakref.o  Modules/_functoolsmodule.o  Modules/_operator.o  Modules/_collectionsmodule.o  Modules/_abc.o  Modules/itertoolsmodule.o  Modules/atexitmodule.o  Modules/signalmodule.o  Modules/_stat.o  Modules/timemodule.o  Modules/_threadmodule.o  Modules/_localemodule.o  Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o  Modules/faulthandler.o  Modules/_tracemalloc.o  Modules/symtablemodule.o  Modules/xxsubtype.o Python/frozen.o  
-lcrypt -ldl   -framework CoreFoundation

xPack x86_64 clang version 15.0.7 (https://github.com/xpack-dev-tools/clang-xpack 51cf67b2d98f2d8e71b99f52d99a0ec17b841236)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Users/ilg/Work/meson-build-xpack.git/build/darwin-x64/xpacks/.bin
 "/usr/bin/ld" -demangle -lto_library /Users/ilg/Library/xPacks/@xpack-dev-tools/clang/15.0.7-1.1/.content/lib/libLTO.dylib -dynamic -dylib -arch x86_64 -macosx_version_min 12.6.0 -syslibroot /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -undefined dynamic_lookup -undefined dynamic_lookup -o libpython3.10.dylib -L/Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib -L/Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib -single_module -macosx_version_min 10.13 -headerpad_max_install_names -dead_strip -rpath /Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib -macosx_version_min 10.13 -headerpad_max_install_names -dead_strip -rpath /Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib -export_dynamic -install_name /Users/ilg/Work/meson-build-0.62.2-1/darwin-x64/x86_64-apple-darwin21.6.0/install/lib/libpython3.10.dylib -compatibility_version 3.10 -current_version 3.10 Modules/getbuildinfo.o Parser/token.o Parser/pegen.o Parser/parser.o Parser/string_parser.o Parser/peg_api.o Parser/myreadline.o Parser/tokenizer.o Objects/abstract.o Objects/accu.o Objects/boolobject.o Objects/bytes_methods.o Objects/bytearrayobject.o Objects/bytesobject.o Objects/call.o Objects/capsule.o Objects/cellobject.o Objects/classobject.o Objects/codeobject.o Objects/complexobject.o Objects/descrobject.o Objects/enumobject.o Objects/exceptions.o Objects/genericaliasobject.o Objects/genobject.o Objects/fileobject.o Objects/floatobject.o Objects/frameobject.o Objects/funcobject.o Objects/interpreteridobject.o Objects/iterobject.o Objects/listobject.o Objects/longobject.o Objects/dictobject.o Objects/odictobject.o Objects/memoryobject.o Objects/methodobject.o Objects/moduleobject.o Objects/namespaceobject.o Objects/object.o Objects/obmalloc.o Objects/picklebufobject.o Objects/rangeobject.o Objects/setobject.o Objects/sliceobject.o Objects/structseq.o Objects/tupleobject.o Objects/typeobject.o Objects/unicodeobject.o Objects/unicodectype.o Objects/unionobject.o Objects/weakrefobject.o Python/_warnings.o Python/Python-ast.o Python/asdl.o Python/ast.o Python/ast_opt.o Python/ast_unparse.o Python/bltinmodule.o Python/ceval.o Python/codecs.o Python/compile.o Python/context.o Python/dynamic_annotations.o Python/errors.o Python/frozenmain.o Python/future.o Python/getargs.o Python/getcompiler.o Python/getcopyright.o Python/getplatform.o Python/getversion.o Python/hamt.o Python/hashtable.o Python/import.o Python/importdl.o Python/initconfig.o Python/marshal.o Python/modsupport.o Python/mysnprintf.o Python/mystrtoul.o Python/pathconfig.o Python/preconfig.o Python/pyarena.o Python/pyctype.o Python/pyfpe.o Python/pyhash.o Python/pylifecycle.o Python/pymath.o Python/pystate.o Python/pythonrun.o Python/pytime.o Python/bootstrap_hash.o Python/structmember.o Python/symtable.o Python/sysmodule.o Python/thread.o Python/traceback.o Python/getopt.o Python/pystrcmp.o Python/pystrtod.o Python/pystrhex.o Python/dtoa.o Python/formatter_unicode.o Python/fileutils.o Python/suggestions.o Python/dynload_shlib.o Modules/config.o Modules/getpath.o Modules/main.o Modules/gcmodule.o Modules/posixmodule.o Modules/errnomodule.o Modules/pwdmodule.o Modules/_sre.o Modules/_codecsmodule.o Modules/_weakref.o Modules/_functoolsmodule.o Modules/_operator.o Modules/_collectionsmodule.o Modules/_abc.o Modules/itertoolsmodule.o Modules/atexitmodule.o Modules/signalmodule.o Modules/_stat.o Modules/timemodule.o Modules/_threadmodule.o Modules/_localemodule.o Modules/_iomodule.o Modules/iobase.o Modules/fileio.o Modules/bytesio.o Modules/bufferedio.o Modules/textio.o Modules/stringio.o Modules/faulthandler.o Modules/_tracemalloc.o Modules/symtablemodule.o Modules/xxsubtype.o Python/frozen.o -lcrypt -ldl -framework CoreFoundation /Users/ilg/Library/xPacks/@xpack-dev-tools/clang/15.0.7-1.1/.content/lib/clang/15.0.7/lib/darwin/libclang_rt.profile_osx.a -sectalign __DATA __llvm_prf_cnts 0x4000 -sectalign __DATA __llvm_prf_data 0x4000 -lSystem /Users/ilg/Library/xPacks/@xpack-dev-tools/clang/15.0.7-1.1/.content/lib/clang/15.0.7/lib/darwin/libclang_rt.osx.a
ld: warning: passed two min versions (12.6, 10.13) for platform macOS. Using 10.13.
ld: warning: passed two min versions (10.13, 10.13) for platform macOS. Using 10.13.
ld: file not found: /Users/ilg/Library/xPacks/@xpack-dev-tools/clang/15.0.7-1.1/.content/lib/clang/15.0.7/lib/darwin/libclang_rt.profile_osx.a
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [libpython3.10.dylib] Error 1
make[3]: *** Waiting for unfinished jobs....
make[2]: *** [build_all_generate_profile] Error 2
make[1]: *** [profile-gen-stamp] Error 2
make: *** [profile-run-stamp] Error 2

Checking the folder shows only two libraries:

% ls -l lib/clang/15.0.7/lib/darwin
total 1408
-rw-r--r--  1 ilg  staff  351584 Jan 21 11:52 libclang_rt.cc_kext.a
-rw-r--r--  1 ilg  staff  365280 Jan 21 11:52 libclang_rt.osx.a

In a complete distribution, this should have been:

% ls -l lib/clang/15.0.7/lib/darwin
total 57512
-rwxr-xr-x  1 ilg  staff   972320 Jan 26 19:25 libclang_rt.asan_osx_dynamic.dylib
-rw-r--r--  1 ilg  staff   349376 Jan 26 19:25 libclang_rt.cc_kext.a
-rw-r--r--  1 ilg  staff      856 Jan 26 19:25 libclang_rt.fuzzer_interceptors_osx.a
-rw-r--r--  1 ilg  staff  8367400 Jan 26 19:25 libclang_rt.fuzzer_no_main_osx.a
-rw-r--r--  1 ilg  staff  8386320 Jan 26 19:25 libclang_rt.fuzzer_osx.a
-rwxr-xr-x  1 ilg  staff   386376 Jan 26 19:25 libclang_rt.lsan_osx_dynamic.dylib
-rw-r--r--  1 ilg  staff  3570528 Jan 26 19:25 libclang_rt.orc_osx.a
-rw-r--r--  1 ilg  staff   363072 Jan 26 19:25 libclang_rt.osx.a
-rw-r--r--  1 ilg  staff   101192 Jan 26 19:25 libclang_rt.profile_osx.a
-rw-r--r--  1 ilg  staff     8520 Jan 26 19:25 libclang_rt.stats_client_osx.a
-rwxr-xr-x  1 ilg  staff   164872 Jan 26 19:25 libclang_rt.stats_osx_dynamic.dylib
-rwxr-xr-x  1 ilg  staff  1102384 Jan 26 19:25 libclang_rt.tsan_osx_dynamic.dylib
-rw-r--r--  1 ilg  staff    35848 Jan 26 19:25 libclang_rt.ubsan_minimal_osx.a
-rwxr-xr-x  1 ilg  staff    42872 Jan 26 19:25 libclang_rt.ubsan_minimal_osx_dynamic.dylib
-rw-r--r--  1 ilg  staff  2692216 Jan 26 19:25 libclang_rt.ubsan_osx.a
-rwxr-xr-x  1 ilg  staff   286368 Jan 26 19:25 libclang_rt.ubsan_osx_dynamic.dylib
-rw-r--r--  1 ilg  staff    84088 Jan 26 19:25 libclang_rt.xray-basic_osx.a
-rw-r--r--  1 ilg  staff   172928 Jan 26 19:25 libclang_rt.xray-fdr_osx.a
-rw-r--r--  1 ilg  staff   342368 Jan 26 19:25 libclang_rt.xray-profiling_osx.a
-rw-r--r--  1 ilg  staff  1971744 Jan 26 19:25 libclang_rt.xray_osx.a
ilg-ul commented 1 year ago

Fixed on 2023-01-28 in 15.0.7-2.

The issue was caused by the explicit -mmacosx-version-min= in the compiler flags, which confused the CMake scripts.

The solution was to filter it out and use the CMake CMAKE_OSX_DEPLOYMENT_TARGET= variable.