Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linker log spam when building on Mac #52411

Closed
eseidel opened this issue May 16, 2023 · 24 comments
Closed

Linker log spam when building on Mac #52411

eseidel opened this issue May 16, 2023 · 24 comments
Labels
area-infrastructure Use area-infrastructure for SDK infrastructure issues, like continuous integration bot changes.

Comments

@eseidel
Copy link
Contributor

eseidel commented May 16, 2023

I'm on 85d09eb.

eseidel@erics-mbp sdk % ./tools/build.py --no-goma --mode release --arch arm64 most
Generating Xcode projects took 25ms
Done. Made 396 targets from 116 files in 648ms
buildtools/ninja/ninja -C xcodebuild/ReleaseARM64 most
ninja: Entering directory `xcodebuild/ReleaseARM64'
[302/782] LINK ./dart_precompiled_runtime
ld64.lld: warning: directory not found for option -L/usr/local/lib
[345/782] LINK ./dart_precompiled_runtime_product
ld64.lld: warning: directory not found for option -L/usr/local/lib
[409/782] LINK ./gen_snapshot
ld64.lld: warning: directory not found for option -L/usr/local/lib
[466/782] LINK ./gen_snapshot_product
ld64.lld: warning: directory not found for option -L/usr/local/lib
[575/782] LINK ./dart
ld64.lld: warning: directory not found for option -L/usr/local/lib
[721/782] LINK ./run_vm_tests
ld64.lld: warning: directory not found for option -L/usr/local/lib
[782/782] STAMP obj/most.stamp
The build took 153.113 seconds

I haven't yet figured out where the flag is coming from, but I will and plan to post a patch to fix if someone doesn't beat me to it.

@lrhn lrhn added the area-infrastructure Use area-infrastructure for SDK infrastructure issues, like continuous integration bot changes. label May 16, 2023
@eseidel
Copy link
Contributor Author

eseidel commented May 17, 2023

I'm told that this is a hard-coded path in clang, and the fix is to just create an empty directory in /usr/lib/local.

Not sure if this warrants an update to https://github.com/dart-lang/sdk/wiki/Building or not? FYI @mraleph

@gautam1103
Copy link

Hey I want contribute , if it is not resolved yet kindly reply me ASAP.

@mraleph
Copy link
Member

mraleph commented May 22, 2023

@eseidel I can't reproduce this. What XCode version are you using? Can you delete one of the binaries (e.g. dart_precompiled_runtime) and then run buildtools/ninja/ninja -v -C xcodebuild/ReleaseARM64 dart_precompiled_runtime. I am curious to see the command line.

@eseidel
Copy link
Contributor Author

eseidel commented May 22, 2023

on 86c1825

It only reproduces if you don't have /usr/local/lib, which I made an empty one to make it go away. If I delete my empty one (yours may not be empty), then it comes back:

eseidel@erics-mbp sdk % ls /usr/local/lib
eseidel@erics-mbp sdk % sudo rmdir /usr/local/lib
Password:
eseidel@erics-mbp sdk % ls /usr/local/lib        
ls: /usr/local/lib: No such file or directory
eseidel@erics-mbp sdk % ./tools/build.py --no-goma --mode release --arch arm64 dart_precompiled_runtime
Generating Xcode projects took 24ms
Done. Made 396 targets from 116 files in 899ms
buildtools/ninja/ninja -C xcodebuild/ReleaseARM64 dart_precompiled_runtime
ninja: Entering directory `xcodebuild/ReleaseARM64'
[411/411] LINK ./dart_precompiled_runtime
ld64.lld: warning: directory not found for option -L/usr/local/lib
The build took 21.244 seconds

@eseidel
Copy link
Contributor Author

eseidel commented May 22, 2023

Just rming the binary doesn't repro:

eseidel@erics-mbp sdk % rm xcodebuild/ReleaseARM64/dart_precompiled_runtime
eseidel@erics-mbp sdk % buildtools/ninja/ninja -v -C xcodebuild/ReleaseARM64 dart_precompiled_runtime  
ninja: Entering directory `xcodebuild/ReleaseARM64'
[1/1] ../../buildtools/mac-arm64/clang/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Wl,-add_empty_section,__CUSTOM,__space_for_note -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./dart_precompiled_runtime -Wl,-filelist,./dart_precompiled_runtime.rsp  -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices && strip -x -o ./exe.stripped/dart_precompiled_runtime ./dart_precompiled_runtime

@eseidel
Copy link
Contributor Author

eseidel commented May 22, 2023

This repo'd:

eseidel@erics-mbp sdk % rm xcodebuild/ReleaseARM64/gen_*
eseidel@erics-mbp sdk % ./tools/build.py --no-goma --mode release --arch arm64 runtime
Generating Xcode projects took 24ms
Done. Made 396 targets from 116 files in 495ms
buildtools/ninja/ninja -C xcodebuild/ReleaseARM64 runtime
ninja: Entering directory `xcodebuild/ReleaseARM64'
[1/41] LINK ./gen_snapshot
ld64.lld: warning: directory not found for option -L/usr/local/lib
[21/41] LINK ./dart
ld64.lld: warning: directory not found for option -L/usr/local/lib
[22/41] LINK ./run_vm_tests
ld64.lld: warning: directory not found for option -L/usr/local/lib
[41/41] STAMP obj/runtime.stamp
The build took 11.130 seconds

@eseidel
Copy link
Contributor Author

eseidel commented May 22, 2023

But doing the same with ninja directly did not!? So confused.

eseidel@erics-mbp sdk % rm xcodebuild/ReleaseARM64/gen_*                              
eseidel@erics-mbp sdk % buildtools/ninja/ninja  -v -C xcodebuild/ReleaseARM64 runtime
ninja: Entering directory `xcodebuild/ReleaseARM64'
[1/41] ../../buildtools/mac-arm64/clang/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./gen_snapshot -Wl,-filelist,./gen_snapshot.rsp  -ldl -lpthread -framework CoreFoundation -framework CoreServices -framework Foundation && strip -x -o ./exe.stripped/gen_snapshot ./gen_snapshot
[2/41] python3 ../../build/gn_run_binary.py compiled_action gen_snapshot --sound-null-safety --deterministic --snapshot_kind=core --vm_snapshot_data=gen/runtime/bin/vm_snapshot_data.bin --vm_snapshot_instructions=gen/runtime/bin/vm_snapshot_instructions.bin --isolate_snapshot_data=gen/runtime/bin/isolate_snapshot_data.bin --isolate_snapshot_instructions=gen/runtime/bin/isolate_snapshot_instructions.bin vm_platform_strong_stripped.dill
[3/41] touch obj/runtime/bin/generate_snapshot_bin.stamp
[4/41] python3 ../../runtime/tools/bin_to_assembly.py --input gen/runtime/bin/vm_snapshot_instructions.bin --output gen/runtime/bin/vm_snapshot_instructions.bin.S --symbol_name kDartVmSnapshotInstructions --target_os mac --executable --incbin
[5/41] python3 ../../runtime/tools/bin_to_assembly.py --input gen/runtime/bin/isolate_snapshot_instructions.bin --output gen/runtime/bin/isolate_snapshot_instructions.bin.S --symbol_name kDartCoreIsolateSnapshotInstructions --target_os mac --executable --incbin
[6/41] python3 ../../runtime/tools/bin_to_assembly.py --input gen/runtime/bin/vm_snapshot_data.bin --output gen/runtime/bin/vm_snapshot_data.bin.S --symbol_name kDartVmSnapshotData --target_os mac --incbin
[7/41] touch obj/runtime/bin/vm_snapshot_instructions_linkable.stamp
[8/41] touch obj/runtime/bin/isolate_snapshot_instructions_linkable.stamp
[9/41] touch obj/runtime/bin/vm_snapshot_data_linkable.stamp
[10/41] python3 ../../runtime/tools/bin_to_assembly.py --input gen/runtime/bin/isolate_snapshot_data.bin --output gen/runtime/bin/isolate_snapshot_data.bin.S --symbol_name kDartCoreIsolateSnapshotData --target_os mac --incbin
[11/41] touch obj/runtime/bin/isolate_snapshot_data_linkable.stamp
[12/41] touch obj/runtime/bin/dart.inputdeps.stamp
[13/41] touch obj/runtime/bin/dart_snapshot_cc.inputdeps.stamp
[14/41] touch obj/runtime/bin/ffi_test_functions.inputdeps.stamp
[15/41] touch obj/runtime/bin/run_vm_tests.inputdeps.stamp
[16/41] ../../buildtools/mac-arm64/clang/bin/clang -MMD -MF obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.isolate_snapshot_instructions.bin.o.d -DTOOLCHAIN_VERSION=pU-dZi3IkAPM8t7_AA8Lu3UzRj1R7ryenNcdn1trZ3oC -DNDEBUG -I../.. -Igen -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -arch arm64 -fPIE -fcolor-diagnostics -std=c99 -c gen/runtime/bin/isolate_snapshot_instructions.bin.S -o obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.isolate_snapshot_instructions.bin.o
[17/41] ../../buildtools/mac-arm64/clang/bin/clang -MMD -MF obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.vm_snapshot_data.bin.o.d -DTOOLCHAIN_VERSION=pU-dZi3IkAPM8t7_AA8Lu3UzRj1R7ryenNcdn1trZ3oC -DNDEBUG -I../.. -Igen -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -arch arm64 -fPIE -fcolor-diagnostics -std=c99 -c gen/runtime/bin/vm_snapshot_data.bin.S -o obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.vm_snapshot_data.bin.o
[18/41] ../../buildtools/mac-arm64/clang/bin/clang -MMD -MF obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.vm_snapshot_instructions.bin.o.d -DTOOLCHAIN_VERSION=pU-dZi3IkAPM8t7_AA8Lu3UzRj1R7ryenNcdn1trZ3oC -DNDEBUG -I../.. -Igen -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -arch arm64 -fPIE -fcolor-diagnostics -std=c99 -c gen/runtime/bin/vm_snapshot_instructions.bin.S -o obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.vm_snapshot_instructions.bin.o
[19/41] ../../buildtools/mac-arm64/clang/bin/clang -MMD -MF obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.isolate_snapshot_data.bin.o.d -DTOOLCHAIN_VERSION=pU-dZi3IkAPM8t7_AA8Lu3UzRj1R7ryenNcdn1trZ3oC -DNDEBUG -I../.. -Igen -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -arch arm64 -fPIE -fcolor-diagnostics -std=c99 -c gen/runtime/bin/isolate_snapshot_data.bin.S -o obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.isolate_snapshot_data.bin.o
[20/41] touch obj/runtime/bin/dart_snapshot_cc.stamp
[21/41] ../../buildtools/mac-arm64/clang/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./dart -Wl,-filelist,./dart.rsp  -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices && strip -x -o ./exe.stripped/dart ./dart
[22/41] ../../buildtools/mac-arm64/clang/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./run_vm_tests -Wl,-filelist,./run_vm_tests.rsp  -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices && strip -x -o ./exe.stripped/run_vm_tests ./run_vm_tests
[23/41] python3 ../../build/gn_run_binary.py compiled_action dart --deterministic --packages=../../.dart_tool/package_config.json --snapshot=gen/dds.dart.snapshot --snapshot-depfile=gen/dds.dart.snapshot.d --snapshot-kind=app-jit --dfe=../../utils/dds/NEVER_LOADED gen/utils/dds/generate_dds_snapshot.dart.dill
[24/41] touch obj/utils/dds/generate_dds_snapshot.stamp
[25/41] ln -f gen/dds.dart.snapshot dds.dart.snapshot 2>/dev/null || (rm -rf dds.dart.snapshot && cp -af gen/dds.dart.snapshot dds.dart.snapshot)
[26/41] touch obj/utils/dds/copy_dds_snapshot.stamp
[27/41] touch obj/utils/dds/dds.stamp
[28/41] python3 ../../build/gn_run_binary.py compiled_action ../../tools/sdks/dart-sdk/bin/dart -Dsdk_hash=86c18251b4 --dfe=../../tools/sdks/dart-sdk/bin/snapshots/kernel-service.dart.snapshot gen/utils/gen_kernel/bootstrap_gen_kernel.dill --packages=../../.dart_tool/package_config.json --platform=vm_platform_strong.dill --no-aot --no-embed-sources --no-link-platform --output=gen/utils/dartdev/generate_dartdev_snapshot.dart.dill --depfile=gen/utils/dartdev/generate_dartdev_snapshot.dart.dill.d -Dsdk_hash=86c18251b4 -Ddart.vm.product=false ../../pkg/dartdev/bin/dartdev.dart
[29/41] touch obj/utils/dartdev/generate_dartdev_snapshot_dill.stamp
[30/41] python3 ../../build/gn_run_binary.py compiled_action ../../tools/sdks/dart-sdk/bin/dart -Dsdk_hash=86c18251b4 --dfe=../../tools/sdks/dart-sdk/bin/snapshots/kernel-service.dart.snapshot gen/utils/gen_kernel/bootstrap_gen_kernel.dill --packages=../../.dart_tool/package_config.json --platform=vm_platform_strong.dill --no-aot --no-embed-sources --no-link-platform --output=gen/utils/dartdev/generate_dartdev_kernel.dart.dill --depfile=gen/utils/dartdev/generate_dartdev_kernel.dart.dill.d -Dsdk_hash=86c18251b4 -Ddart.vm.product=false ../../pkg/dartdev/bin/dartdev.dart
[31/41] touch obj/utils/dartdev/generate_dartdev_kernel_dill.stamp
[32/41] ln -f gen/utils/dartdev/generate_dartdev_kernel.dart.dill gen/dartdev.dill 2>/dev/null || (rm -rf gen/dartdev.dill && cp -af gen/utils/dartdev/generate_dartdev_kernel.dart.dill gen/dartdev.dill)
[33/41] touch obj/utils/dartdev/generate_dartdev_kernel.stamp
[34/41] ln -f gen/dartdev.dill dartdev.dill 2>/dev/null || (rm -rf dartdev.dill && cp -af gen/dartdev.dill dartdev.dill)
[35/41] touch obj/utils/dartdev/copy_dartdev_kernel.stamp
[36/41] python3 ../../build/gn_run_binary.py compiled_action dart --deterministic --packages=../../.dart_tool/package_config.json --snapshot=gen/dartdev.dart.snapshot --snapshot-depfile=gen/dartdev.dart.snapshot.d --sound-null-safety --snapshot-kind=app-jit --dfe=../../utils/dartdev/NEVER_LOADED gen/utils/dartdev/generate_dartdev_snapshot.dart.dill --help
[37/41] touch obj/utils/dartdev/generate_dartdev_snapshot.stamp
[38/41] ln -f gen/dartdev.dart.snapshot dartdev.dart.snapshot 2>/dev/null || (rm -rf dartdev.dart.snapshot && cp -af gen/dartdev.dart.snapshot dartdev.dart.snapshot)
[39/41] touch obj/utils/dartdev/copy_dartdev_snapshot.stamp
[40/41] touch obj/utils/dartdev/dartdev.stamp
[41/41] touch obj/runtime.stamp

@mraleph
Copy link
Member

mraleph commented May 22, 2023

@eseidel can you also run build.py with -v? We can then try to compare the output when it repros.

@eseidel
Copy link
Contributor Author

eseidel commented May 22, 2023

Repro:

eseidel@erics-mbp sdk % rm xcodebuild/ReleaseARM64/gen_*                             
eseidel@erics-mbp sdk % ./tools/build.py --no-goma --mode release --arch arm64 runtime -v
gn gen --check in xcodebuild/ReleaseARM64
Generating Xcode projects took 22ms
Done. Made 396 targets from 116 files in 492ms
buildtools/ninja/ninja -C xcodebuild/ReleaseARM64 -v runtime
ninja: Entering directory `xcodebuild/ReleaseARM64'
[1/41] ../../buildtools/mac-arm64/clang/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./gen_snapshot -Wl,-filelist,./gen_snapshot.rsp  -ldl -lpthread -framework CoreFoundation -framework CoreServices -framework Foundation && strip -x -o ./exe.stripped/gen_snapshot ./gen_snapshot
ld64.lld: warning: directory not found for option -L/usr/local/lib
[2/41] python3 ../../build/gn_run_binary.py compiled_action gen_snapshot --sound-null-safety --deterministic --snapshot_kind=core --vm_snapshot_data=gen/runtime/bin/vm_snapshot_data.bin --vm_snapshot_instructions=gen/runtime/bin/vm_snapshot_instructions.bin --isolate_snapshot_data=gen/runtime/bin/isolate_snapshot_data.bin --isolate_snapshot_instructions=gen/runtime/bin/isolate_snapshot_instructions.bin vm_platform_strong_stripped.dill
[3/41] touch obj/runtime/bin/generate_snapshot_bin.stamp
[4/41] python3 ../../runtime/tools/bin_to_assembly.py --input gen/runtime/bin/isolate_snapshot_instructions.bin --output gen/runtime/bin/isolate_snapshot_instructions.bin.S --symbol_name kDartCoreIsolateSnapshotInstructions --target_os mac --executable --incbin
[5/41] python3 ../../runtime/tools/bin_to_assembly.py --input gen/runtime/bin/vm_snapshot_instructions.bin --output gen/runtime/bin/vm_snapshot_instructions.bin.S --symbol_name kDartVmSnapshotInstructions --target_os mac --executable --incbin
[6/41] python3 ../../runtime/tools/bin_to_assembly.py --input gen/runtime/bin/vm_snapshot_data.bin --output gen/runtime/bin/vm_snapshot_data.bin.S --symbol_name kDartVmSnapshotData --target_os mac --incbin
[7/41] touch obj/runtime/bin/vm_snapshot_instructions_linkable.stamp
[8/41] touch obj/runtime/bin/vm_snapshot_data_linkable.stamp
[9/41] touch obj/runtime/bin/isolate_snapshot_instructions_linkable.stamp
[10/41] python3 ../../runtime/tools/bin_to_assembly.py --input gen/runtime/bin/isolate_snapshot_data.bin --output gen/runtime/bin/isolate_snapshot_data.bin.S --symbol_name kDartCoreIsolateSnapshotData --target_os mac --incbin
[11/41] touch obj/runtime/bin/isolate_snapshot_data_linkable.stamp
[12/41] touch obj/runtime/bin/dart.inputdeps.stamp
[13/41] touch obj/runtime/bin/dart_snapshot_cc.inputdeps.stamp
[14/41] touch obj/runtime/bin/run_vm_tests.inputdeps.stamp
[15/41] touch obj/runtime/bin/ffi_test_functions.inputdeps.stamp
[16/41] ../../buildtools/mac-arm64/clang/bin/clang -MMD -MF obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.isolate_snapshot_instructions.bin.o.d -DTOOLCHAIN_VERSION=pU-dZi3IkAPM8t7_AA8Lu3UzRj1R7ryenNcdn1trZ3oC -DNDEBUG -I../.. -Igen -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -arch arm64 -fPIE -fcolor-diagnostics -std=c99 -c gen/runtime/bin/isolate_snapshot_instructions.bin.S -o obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.isolate_snapshot_instructions.bin.o
[17/41] ../../buildtools/mac-arm64/clang/bin/clang -MMD -MF obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.vm_snapshot_instructions.bin.o.d -DTOOLCHAIN_VERSION=pU-dZi3IkAPM8t7_AA8Lu3UzRj1R7ryenNcdn1trZ3oC -DNDEBUG -I../.. -Igen -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -arch arm64 -fPIE -fcolor-diagnostics -std=c99 -c gen/runtime/bin/vm_snapshot_instructions.bin.S -o obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.vm_snapshot_instructions.bin.o
[18/41] ../../buildtools/mac-arm64/clang/bin/clang -MMD -MF obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.vm_snapshot_data.bin.o.d -DTOOLCHAIN_VERSION=pU-dZi3IkAPM8t7_AA8Lu3UzRj1R7ryenNcdn1trZ3oC -DNDEBUG -I../.. -Igen -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -arch arm64 -fPIE -fcolor-diagnostics -std=c99 -c gen/runtime/bin/vm_snapshot_data.bin.S -o obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.vm_snapshot_data.bin.o
[19/41] ../../buildtools/mac-arm64/clang/bin/clang -MMD -MF obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.isolate_snapshot_data.bin.o.d -DTOOLCHAIN_VERSION=pU-dZi3IkAPM8t7_AA8Lu3UzRj1R7ryenNcdn1trZ3oC -DNDEBUG -I../.. -Igen -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -arch arm64 -fPIE -fcolor-diagnostics -std=c99 -c gen/runtime/bin/isolate_snapshot_data.bin.S -o obj/BUILD_DIR/gen/runtime/bin/dart_snapshot_cc.isolate_snapshot_data.bin.o
[20/41] touch obj/runtime/bin/dart_snapshot_cc.stamp
[21/41] ../../buildtools/mac-arm64/clang/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./dart -Wl,-filelist,./dart.rsp  -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices && strip -x -o ./exe.stripped/dart ./dart
ld64.lld: warning: directory not found for option -L/usr/local/lib
[22/41] ../../buildtools/mac-arm64/clang/bin/clang++ -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./run_vm_tests -Wl,-filelist,./run_vm_tests.rsp  -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices && strip -x -o ./exe.stripped/run_vm_tests ./run_vm_tests
ld64.lld: warning: directory not found for option -L/usr/local/lib
[23/41] python3 ../../build/gn_run_binary.py compiled_action dart --deterministic --packages=../../.dart_tool/package_config.json --snapshot=gen/dds.dart.snapshot --snapshot-depfile=gen/dds.dart.snapshot.d --snapshot-kind=app-jit --dfe=../../utils/dds/NEVER_LOADED gen/utils/dds/generate_dds_snapshot.dart.dill
[24/41] touch obj/utils/dds/generate_dds_snapshot.stamp
[25/41] ln -f gen/dds.dart.snapshot dds.dart.snapshot 2>/dev/null || (rm -rf dds.dart.snapshot && cp -af gen/dds.dart.snapshot dds.dart.snapshot)
[26/41] touch obj/utils/dds/copy_dds_snapshot.stamp
[27/41] touch obj/utils/dds/dds.stamp
[28/41] python3 ../../build/gn_run_binary.py compiled_action ../../tools/sdks/dart-sdk/bin/dart -Dsdk_hash=86c18251b4 --dfe=../../tools/sdks/dart-sdk/bin/snapshots/kernel-service.dart.snapshot gen/utils/gen_kernel/bootstrap_gen_kernel.dill --packages=../../.dart_tool/package_config.json --platform=vm_platform_strong.dill --no-aot --no-embed-sources --no-link-platform --output=gen/utils/dartdev/generate_dartdev_kernel.dart.dill --depfile=gen/utils/dartdev/generate_dartdev_kernel.dart.dill.d -Dsdk_hash=86c18251b4 -Ddart.vm.product=false ../../pkg/dartdev/bin/dartdev.dart
[29/41] touch obj/utils/dartdev/generate_dartdev_kernel_dill.stamp
[30/41] python3 ../../build/gn_run_binary.py compiled_action ../../tools/sdks/dart-sdk/bin/dart -Dsdk_hash=86c18251b4 --dfe=../../tools/sdks/dart-sdk/bin/snapshots/kernel-service.dart.snapshot gen/utils/gen_kernel/bootstrap_gen_kernel.dill --packages=../../.dart_tool/package_config.json --platform=vm_platform_strong.dill --no-aot --no-embed-sources --no-link-platform --output=gen/utils/dartdev/generate_dartdev_snapshot.dart.dill --depfile=gen/utils/dartdev/generate_dartdev_snapshot.dart.dill.d -Dsdk_hash=86c18251b4 -Ddart.vm.product=false ../../pkg/dartdev/bin/dartdev.dart
[31/41] ln -f gen/utils/dartdev/generate_dartdev_kernel.dart.dill gen/dartdev.dill 2>/dev/null || (rm -rf gen/dartdev.dill && cp -af gen/utils/dartdev/generate_dartdev_kernel.dart.dill gen/dartdev.dill)
[32/41] touch obj/utils/dartdev/generate_dartdev_snapshot_dill.stamp
[33/41] touch obj/utils/dartdev/generate_dartdev_kernel.stamp
[34/41] ln -f gen/dartdev.dill dartdev.dill 2>/dev/null || (rm -rf dartdev.dill && cp -af gen/dartdev.dill dartdev.dill)
[35/41] touch obj/utils/dartdev/copy_dartdev_kernel.stamp
[36/41] python3 ../../build/gn_run_binary.py compiled_action dart --deterministic --packages=../../.dart_tool/package_config.json --snapshot=gen/dartdev.dart.snapshot --snapshot-depfile=gen/dartdev.dart.snapshot.d --sound-null-safety --snapshot-kind=app-jit --dfe=../../utils/dartdev/NEVER_LOADED gen/utils/dartdev/generate_dartdev_snapshot.dart.dill --help
[37/41] touch obj/utils/dartdev/generate_dartdev_snapshot.stamp
[38/41] ln -f gen/dartdev.dart.snapshot dartdev.dart.snapshot 2>/dev/null || (rm -rf dartdev.dart.snapshot && cp -af gen/dartdev.dart.snapshot dartdev.dart.snapshot)
[39/41] touch obj/utils/dartdev/copy_dartdev_snapshot.stamp
[40/41] touch obj/utils/dartdev/dartdev.stamp
[41/41] touch obj/runtime.stamp
The build took 11.954 seconds

@mraleph
Copy link
Member

mraleph commented May 23, 2023

Ooops, I do actually have /usr/local/lib, but the message does not repro for me even if I remove it temporarily.

I have looked at the LLVM source code and I am puzzled why this error happens. /usr/local/lib is indeed hardcoded path but it should not trigger the warning in the version of the toolchain we are using:

https://github.com/llvm/llvm-project/blob/e8cfbfd05a951b85f80156dffc8eeecb34c7271c/lld/MachO/Driver.cpp#L183-L190

There was a time when it would trigger such a warning but it seems to be have been fixed by llvm/llvm-project@ebac710 which is a three year old commit.

Confusing stuff.

Could you try applying the following patch and reproducing again:

diff --git a/build/toolchain/mac/BUILD.gn b/build/toolchain/mac/BUILD.gn
index 48b6bb03163..3c7478494cc 100644
--- a/build/toolchain/mac/BUILD.gn
+++ b/build/toolchain/mac/BUILD.gn
@@ -180,7 +180,7 @@ template("mac_toolchain") {
         stripped_outfile = "{{root_out_dir}}/exe.stripped/$exename"
       }
 
-      command = "$ld $sysroot_flags $toolchain_flags {{ldflags}} -Xlinker -rpath -Xlinker @executable_path/Frameworks -o $outfile -Wl,-filelist,$rspfile {{solibs}} {{libs}} {{frameworks}}"
+      command = "$ld -v $sysroot_flags $toolchain_flags {{ldflags}} -Xlinker -rpath -Xlinker @executable_path/Frameworks -o $outfile -Wl,-filelist,$rspfile {{solibs}} {{libs}} {{frameworks}}"
       if (defined(invoker.strip)) {
         strip = invoker.strip
         strip_command = "${strip} -x -o $stripped_outfile $outfile"

We should see which linker is invoked and all command line arguments.

@eseidel
Copy link
Contributor Author

eseidel commented May 23, 2023

Here's one:

[52/1057] LINK ./dart
Fuchsia clang version 17.0.0 (https://llvm.googlesource.com/llvm-project 5344d8e10bb7d8672d4bfae8adb010465470d51b)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Users/eseidel/Documents/GitHub/dart-sdk/sdk/xcodebuild/DebugARM64/../../buildtools/mac-arm64/clang/bin
 "/Users/eseidel/Documents/GitHub/dart-sdk/sdk/xcodebuild/DebugARM64/../../buildtools/mac-arm64/clang/bin/ld64.lld" -demangle -export_dynamic -dynamic -arch arm64 -platform_version macos 11.0.0 13.3 -pie -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -undefined dynamic_lookup -undefined dynamic_lookup -o ./dart -L. -L/usr/local/lib ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -search_paths_first -rpath @loader_path/. -rpath @loader_path/../../.. -pie -rpath @executable_path/Frameworks -filelist ./dart.rsp -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices -lSystem /Users/eseidel/Documents/GitHub/dart-sdk/sdk/buildtools/mac-arm64/clang/lib/clang/17/lib/darwin/libclang_rt.osx.a
ld64.lld: warning: directory not found for option -L/usr/local/lib

@mraleph
Copy link
Member

mraleph commented May 23, 2023

@eseidel ah-ha. There is an explicit -L/use/local/lib snuck from somewhere. Now we need to figure out where that comes from. I assume your checkout is otherwise clean and no changes in the buildroot / toolchain configuration files? Can you check your environment variables just in case?

@eseidel
Copy link
Contributor Author

eseidel commented May 23, 2023

Yes, that's from a clean checkout of 86c1825

@eseidel
Copy link
Contributor Author

eseidel commented May 23, 2023

I (unfortunately) have brew installed, which also could have messed with things somehow?

@eseidel
Copy link
Contributor Author

eseidel commented May 23, 2023

__CFBundleIdentifier=com.apple.Terminal
TMPDIR=/var/folders/fv/fqqmfjqd6zvdqrbrv78gt4m80000gn/T/
XPC_FLAGS=0x0
TERM=xterm-256color
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.bUuXRRtE2f/Listeners
XPC_SERVICE_NAME=0
TERM_PROGRAM=Apple_Terminal
TERM_PROGRAM_VERSION=447
TERM_SESSION_ID=49D4DF57-2072-44D3-8A46-96A02E3EE8D1
SHELL=/bin/zsh
HOME=/Users/eseidel
LOGNAME=eseidel
USER=eseidel
PATH=/Users/eseidel/.docker/bin:/Users/eseidel/.shorebird/bin:/Users/eseidel/.pub-cache/bin:/Users/eseidel/Library/Android/sdk/platform-tools:/Users/eseidel/Documents/google-cloud-sdk/bin:/Users/eseidel/Documents/GitHub/upstream_flutter/bin:/Users/eseidel/Documents/GitHub/depot_tools:/Users/eseidel/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/eseidel/.cargo/bin
SHLVL=1
PWD=/Users/eseidel/Documents/GitHub/dart-sdk/sdk
OLDPWD=/Users/eseidel/Documents/GitHub/dart-sdk
HOMEBREW_PREFIX=/opt/homebrew
HOMEBREW_CELLAR=/opt/homebrew/Cellar
HOMEBREW_REPOSITORY=/opt/homebrew
MANPATH=/opt/homebrew/share/man::
INFOPATH=/opt/homebrew/share/info:
CLICOLOR=1
ANDROID_HOME=/Users/eseidel/Library/Android/sdk
NDK_HOME=/Users/eseidel/Library/Android/sdk/ndk/25.2.9519653
NVM_DIR=/Users/eseidel/.nvm
NVM_CD_FLAGS=-q
NVM_RC_VERSION=
LANG=en_US.UTF-8
_=/usr/bin/env

@eseidel
Copy link
Contributor Author

eseidel commented May 23, 2023

I couldn't take the spam and created the directory again. 🤣 sudo mkdir /usr/local/lib

@mraleph
Copy link
Member

mraleph commented May 24, 2023

I think I have to give up for now, because I can't reproduce it and cursory reading of clang sources does not reveal anything that would explain where it got injected from. There is something specific to your system that makes this happen - -L/usr/local/lib just appears out of nowhere in the ld64.lld command line, it is not in the clang++ command line.

@mraleph
Copy link
Member

mraleph commented May 24, 2023

@eseidel just out of curiosity (because the problem does not seem to reproduce when you run ninja directly). What does file $(which python3) show? Is it a ARM64 binary?

@eseidel
Copy link
Contributor Author

eseidel commented May 24, 2023

eseidel@erics-mbp sdk % which python3
/usr/bin/python3
eseidel@erics-mbp sdk % file $(which python3)
/usr/bin/python3: Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64e:Mach-O 64-bit executable arm64e]
/usr/bin/python3 (for architecture x86_64):	Mach-O 64-bit executable x86_64
/usr/bin/python3 (for architecture arm64e):	Mach-O 64-bit executable arm64e
eseidel@erics-mbp sdk % python3 --version
Python 3.9.6
eseidel@erics-mbp sdk % md5 `which python3`
MD5 (/usr/bin/python3) = 8ca8d1b745b6b80c59cb91ff50369d4e

@eseidel
Copy link
Contributor Author

eseidel commented May 24, 2023

Thanks for looking!

@mraleph
Copy link
Member

mraleph commented May 25, 2023

@eseidel I am out of ideas really. One last try. Could you run the following bash script from the SDK root and post the output?

#!/bin/bash

set -ex

pushd xcodebuild/ReleaseARM64

../../buildtools/mac-arm64/clang/bin/clang++ -v -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./dart -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices

python3 <<EOF
import subprocess
import os

process = subprocess.Popen(
    '../../buildtools/mac-arm64/clang/bin/clang++ -v -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14  -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./dart -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices'.split(' '), stdin=None)
process.wait()

print(os.environ)
EOF

popd

@eseidel
Copy link
Contributor Author

eseidel commented May 30, 2023

eseidel@erics-mbp sdk % ./test.sh 
+ pushd xcodebuild/ReleaseARM64
./test.sh: line 5: pushd: xcodebuild/ReleaseARM64: No such file or directory
eseidel@erics-mbp sdk % ./tools/build.py --no-goma --mode release --arch arm64                                                                                        
Generating Xcode projects took 29ms
Done. Made 396 targets from 117 files in 983ms
buildtools/ninja/ninja -C xcodebuild/ReleaseARM64
ninja: Entering directory `xcodebuild/ReleaseARM64'
[113/2325] LINK ./process_test
ld64.lld: warning: directory not found for option -L/usr/local/lib
[2104/2325] LINK ./gen_snapshot
ld64.lld: warning: directory not found for option -L/usr/local/lib
[2166/2325] LINK ./dart
ld64.lld: warning: directory not found for option -L/usr/local/lib
[2168/2325] SOLINK libffi_test_dynamic_library.dylib libffi_test_dynamic_library.dylib.TOC
ld64.lld: warning: directory not found for option -L/usr/local/lib
[2169/2325] SOLINK libentrypoints_verification_test.dylib libentrypoints_verification_test.dylib.TOC
ld64.lld: warning: directory not found for option -L/usr/local/lib
[2210/2325] SOLINK libffi_test_functions.dylib libffi_test_functions.dylib.TOC
ld64.lld: warning: directory not found for option -L/usr/local/lib
[2310/2325] LINK ./run_vm_tests
ld64.lld: warning: directory not found for option -L/usr/local/lib
[2325/2325] STAMP obj/default.stamp
The build took 204.739 seconds
eseidel@erics-mbp sdk % ./test.sh                                             
+ pushd xcodebuild/ReleaseARM64
~/Documents/GitHub/dart-sdk/sdk/xcodebuild/ReleaseARM64 ~/Documents/GitHub/dart-sdk/sdk
+ ../../buildtools/mac-arm64/clang/bin/clang++ -v -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -mmacosx-version-min=10.14 -rdynamic -arch arm64 -fPIE -nostdlib++ ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -Wl,-dead_strip -Wl,-search_paths_first -L. -undefined dynamic_lookup -Wl,-rpath,@loader_path/. -Wl,-rpath,@loader_path/../../.. -Wl,-pie -Xlinker -rpath -Xlinker @executable_path/Frameworks -o ./dart -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices
Fuchsia clang version 17.0.0 (https://llvm.googlesource.com/llvm-project 6d667d4b261e81f325756fdfd5bb43b3b3d2451d)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Users/eseidel/Documents/GitHub/dart-sdk/sdk/xcodebuild/ReleaseARM64/../../buildtools/mac-arm64/clang/bin
 "/Users/eseidel/Documents/GitHub/dart-sdk/sdk/xcodebuild/ReleaseARM64/../../buildtools/mac-arm64/clang/bin/ld64.lld" -demangle -export_dynamic -dynamic -arch arm64 -platform_version macos 11.0.0 13.3 -pie -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -undefined dynamic_lookup -undefined dynamic_lookup -o ./dart -L. ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -dead_strip -search_paths_first -rpath @loader_path/. -rpath @loader_path/../../.. -pie -rpath @executable_path/Frameworks -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices -lSystem /Users/eseidel/Documents/GitHub/dart-sdk/sdk/buildtools/mac-arm64/clang/lib/clang/17/lib/darwin/libclang_rt.osx.a
+ python3
Fuchsia clang version 17.0.0 (https://llvm.googlesource.com/llvm-project 6d667d4b261e81f325756fdfd5bb43b3b3d2451d)
Target: arm64-apple-darwin22.3.0
Thread model: posix
InstalledDir: /Users/eseidel/Documents/GitHub/dart-sdk/sdk/xcodebuild/ReleaseARM64/../../buildtools/mac-arm64/clang/bin
 "/Users/eseidel/Documents/GitHub/dart-sdk/sdk/xcodebuild/ReleaseARM64/../../buildtools/mac-arm64/clang/bin/ld64.lld" -demangle -export_dynamic -dynamic -arch arm64 -platform_version macos 11.0.0 13.3 -pie -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX13.3.sdk -undefined dynamic_lookup -undefined dynamic_lookup -o ./dart -L. -L/usr/local/lib ../../buildtools/mac-arm64/clang/bin/../lib/libc++.a -dead_strip -search_paths_first -rpath @loader_path/. -rpath @loader_path/../../.. -pie -rpath @executable_path/Frameworks -ldl -lpthread -framework CoreFoundation -framework Security -framework Foundation -framework CoreServices -lSystem /Users/eseidel/Documents/GitHub/dart-sdk/sdk/buildtools/mac-arm64/clang/lib/clang/17/lib/darwin/libclang_rt.osx.a
ld64.lld: warning: directory not found for option -L/usr/local/lib
environ({'NVM_INC': '/Users/eseidel/.nvm/versions/node/v18.16.0/include/node', 'MANPATH': '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/usr/share/man:/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/share/man:/Applications/Xcode.app/Contents/Developer/usr/share/man:/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/share/man:/Users/eseidel/.nvm/versions/node/v18.16.0/share/man:/opt/homebrew/share/man:/usr/share/man:/usr/local/share/man:/Users/eseidel/.nvm/versions/node/v18.16.0/share/man:/opt/homebrew/share/man::', 'TERM_PROGRAM': 'vscode', 'NVM_CD_FLAGS': '-q', 'ANDROID_HOME': '/Users/eseidel/Library/Android/sdk', 'TERM': 'xterm-256color', 'SHELL': '/bin/zsh', 'CLICOLOR': '1', 'HOMEBREW_REPOSITORY': '/opt/homebrew', 'TMPDIR': '/var/folders/fv/fqqmfjqd6zvdqrbrv78gt4m80000gn/T/', 'TERM_PROGRAM_VERSION': '1.78.2', 'ZDOTDIR': '/Users/eseidel', 'OLDPWD': '/Users/eseidel/Documents/GitHub/dart-sdk/sdk', 'ORIGINAL_XDG_CURRENT_DESKTOP': 'undefined', 'MallocNanoZone': '0', 'NVM_DIR': '/Users/eseidel/.nvm', 'NDK_HOME': '/Users/eseidel/Library/Android/sdk/ndk/25.2.9519653', 'USER': 'eseidel', 'COMMAND_MODE': 'unix2003', 'SSH_AUTH_SOCK': '/private/tmp/com.apple.launchd.bUuXRRtE2f/Listeners', '__CF_USER_TEXT_ENCODING': '0x1F5:0x0:0x0', 'PATH': '/Users/eseidel/.docker/bin:/Users/eseidel/.shorebird/bin:/Users/eseidel/.nvm/versions/node/v18.16.0/bin:/Users/eseidel/.pub-cache/bin:/Users/eseidel/Library/Android/sdk/platform-tools:/Users/eseidel/Documents/google-cloud-sdk/bin:/Users/eseidel/Documents/GitHub/upstream_flutter/bin:/Users/eseidel/Documents/GitHub/depot_tools:/Users/eseidel/bin:/Users/eseidel/Documents/GitHub/upstream_flutter/bin/cache/dart-sdk/bin/:/Users/eseidel/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/eseidel/Library/Application Support/cloud-code/installer/google-cloud-sdk/bin:/Users/eseidel/Documents/GitHub/upstream_flutter/bin/cache/dart-sdk/bin/:/Users/eseidel/.docker/bin:/Users/eseidel/.shorebird/bin:/Users/eseidel/.nvm/versions/node/v18.16.0/bin:/Users/eseidel/.pub-cache/bin:/Users/eseidel/Library/Android/sdk/platform-tools:/Users/eseidel/Documents/google-cloud-sdk/bin:/Users/eseidel/Documents/GitHub/upstream_flutter/bin:/Users/eseidel/Documents/GitHub/depot_tools:/Users/eseidel/bin:/opt/homebrew/bin:/opt/homebrew/sbin:/Users/eseidel/.cargo/bin', 'USER_ZDOTDIR': '/Users/eseidel', '__CFBundleIdentifier': 'com.microsoft.VSCode', 'PWD': '/Users/eseidel/Documents/GitHub/dart-sdk/sdk/xcodebuild/ReleaseARM64', 'LANG': 'en_US.UTF-8', 'VSCODE_GIT_ASKPASS_EXTRA_ARGS': '--ms-enable-electron-run-as-node', 'XPC_FLAGS': '0x0', 'XPC_SERVICE_NAME': '0', 'VSCODE_INJECTION': '1', 'SHLVL': '2', 'HOME': '/Users/eseidel', 'VSCODE_GIT_ASKPASS_MAIN': '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass-main.js', 'HOMEBREW_PREFIX': '/opt/homebrew', 'LOGNAME': 'eseidel', 'VSCODE_GIT_IPC_HANDLE': '/var/folders/fv/fqqmfjqd6zvdqrbrv78gt4m80000gn/T/vscode-git-b2c0f12614.sock', 'NVM_BIN': '/Users/eseidel/.nvm/versions/node/v18.16.0/bin', 'VSCODE_GIT_ASKPASS_NODE': '/Applications/Visual Studio Code.app/Contents/Frameworks/Code Helper (Plugin).app/Contents/MacOS/Code Helper (Plugin)', 'GIT_ASKPASS': '/Applications/Visual Studio Code.app/Contents/Resources/app/extensions/git/dist/askpass.sh', 'INFOPATH': '/opt/homebrew/share/info:/opt/homebrew/share/info:', 'HOMEBREW_CELLAR': '/opt/homebrew/Cellar', 'COLORTERM': 'truecolor', '_': '/usr/bin/python3', 'SDKROOT': '/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk', 'CPATH': '/usr/local/include', 'LIBRARY_PATH': '/usr/local/lib'})
+ popd
~/Documents/GitHub/dart-sdk/sdk
eseidel@erics-mbp sdk % 

@mraleph
Copy link
Member

mraleph commented May 30, 2023

@eseidel okay, we are getting there. It seems that your Python environment is somehow extended to contain LIBRARY_PATH=/usr/local/lib and that gets picked up by clang driver (maybe here or somewhere else in that file). Your normal environment does not contain this variable so when you run ninja directly you don't get the same error.

Now I can also see the difference between your and my setup: my setup is using homebrew python. If I instead you /usr/bin/python3 then I also get 'LIBRARY_PATH': '/usr/local/lib' in my environment:

$ python3 -c 'import os; print(os.environ["LIBRARY_PATH"]);'
Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/opt/homebrew/Cellar/python@3.10/3.10.9/Frameworks/Python.framework/Versions/3.10/lib/python3.10/os.py", line 680, in __getitem__
    raise KeyError(key) from None
KeyError: 'LIBRARY_PATH'
$ /usr/bin/python3 -c 'import os; print(os.environ["LIBRARY_PATH"]);'
/usr/local/lib

Okay, a bit more searching around and I found: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4149962 and corresponding https://openradar.appspot.com/radar?id=5608755232243712 from @nico

I will just apply the same workaround in our build.py.

@eseidel
Copy link
Contributor Author

eseidel commented May 30, 2023

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-infrastructure Use area-infrastructure for SDK infrastructure issues, like continuous integration bot changes.
Projects
None yet
Development

No branches or pull requests

4 participants