zig cc helloworld.c -o helloworld_zig_cc_trunk failed to create a binary on linux-x86_64
Zig Version
0.10.0-dev.4403+f9192adab
Steps to Reproduce
using current prebuild binary
using a default helloworld.c in /somewhere/hello/:
#include <stdio.h>
int main(int argc, char **argv) { printf("Hello World\n"); return 0; }
zig cc helloworld.c -o helloworld_zig_cc_trunk LLD Link... ld.lld: error: cannot open pwd: /somewhere/crt1.o: No such file or directory ld.lld: error: cannot open pwd: /somewhere/crti.o: No such file or directory ld.lld: error: cannot open pwd: /somewhere/crtn.o: No such file or directory
zig-linux-x86_64-0.10.0-dev.4357+b4e342459 fails also zig-linux-x86_64-0.10.0-dev.3475+b3d463c9e works
Deleting $HOME/.cache/zig does not change the failure
Expected Behavior
a binary that can be started
Actual Behavior
zig cc helloworld.c -o helloworld_zig_cc_trunk LLD Link... ld.lld: error: cannot open pwd: /somewhere/crt1.o: No such file or directory ld.lld: error: cannot open pwd: /somewhere/crti.o: No such file or directory ld.lld: error: cannot open pwd: /somewhere/crtn.o: No such file or directory
works fine for me on 0.10.0-dev.4369+1087e6776
works fine for me on
0.10.0-dev.4369+1087e6776
Strange.... With the prebuild linux-x86_64 binary?
sha256sum zig-linux-x86_64-0.10.0-dev.4369+1087e6776.tar.xz 1fc04720953933f3c09074e505cf7b046773e0cb8f419236fd72966ecbca5483 zig-linux-x86_64-0.10.0-dev.4369+1087e6776.tar.xz
Fails here:
my_ps1:/somewhere/hello$ zig cc helloworld.c -o helloworld_zig_4369 LLD Link... ld.lld: error: cannot open pwd: /somewhere/crt1.o: No such file or directory ld.lld: error: cannot open pwd: /somewhere/crti.o: No such file or directory ld.lld: error: cannot open pwd: /somewhere/crtn.o: No such file or directory my_ps1:/somewhere/hello$ zig version 0.10.0-dev.4369+1087e6776
cache dir was cleared
can you post the output of zig cc helloworld.c -o helloworld_zig_cc --verbose
detlef@i7:/_s/hello$ zig cc helloworld.c -o helloworld_zig_cc --verbose clang version 15.0.0 ([email protected]:ziglang/zig-bootstrap.git 9be8396b715b10f64d8a94b2d0d9acb77126d8ca) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /usr/bin Found candidate GCC installation: /usr/bin/../lib/gcc-cross/i686-linux-gnu/10 Found candidate GCC installation: /usr/bin/../lib/gcc-cross/i686-linux-gnu/11 Found candidate GCC installation: /usr/bin/../lib/gcc-cross/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/bin/../lib/gcc-cross/x86_64-linux-gnu/11 Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/10 Found candidate GCC installation: /usr/bin/../lib/gcc/i686-linux-gnu/11 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/10 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11 Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12 Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12 Candidate multilib: .;@m64 Selected multilib: .;@m64 (in-process) "/data/_v/zig-linux-x86_64-0.10.0-dev.4369+1087e6776/zig" -cc1 -triple x86_64-unknown-linux-gnu -emit-obj -mrelax-all --mrelax-relocations -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name helloworld.c -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -mllvm -treat-scalable-fixed-error-as-warning -debug-info-kind=constructor -dwarf-version=4 -debugger-tuning=gdb -v -fcoverage-compilation-dir=/_s/hello -nostdsysteminc -nobuiltininc -resource-dir /data/_v/lib/clang/15.0.0 -dependency-file /home/detlef/.cache/zig/tmp/230410e59e289cc-helloworld.o.d -MT /home/detlef/.cache/zig/tmp/230410e59e289cc-helloworld.o -sys-header-deps -MV -isystem /data/_v/zig-linux-x86_64-0.10.0-dev.4369+1087e6776/lib/include -isystem /usr/include -isystem /usr/local/include -isystem /usr/include/x86_64-linux-gnu -isystem /usr/include -D GLIBC_MINOR=35 -D _DEBUG -O0 -fdebug-compilation-dir=/_s/hello -ferror-limit 19 -fsanitize=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound -fsanitize-trap=alignment,array-bounds,bool,builtin,enum,float-cast-overflow,function,integer-divide-by-zero,nonnull-attribute,null,pointer-overflow,return,returns-nonnull-attribute,shift-base,shift-exponent,signed-integer-overflow,unreachable,vla-bound -stack-protector 2 -stack-protector-buffer-size 4 -fgnuc-version=4.2.1 -fcolor-diagnostics -fno-spell-checking -target-cpu sandybridge -target-feature -16bit-mode -target-feature -32bit-mode -target-feature -3dnow -target-feature -3dnowa -target-feature +64bit -target-feature -adx -target-feature +aes -target-feature -amx-bf16 -target-feature -amx-int8 -target-feature -amx-tile -target-feature +avx -target-feature -avx2 -target-feature -avx512bf16 -target-feature -avx512bitalg -target-feature -avx512bw -target-feature -avx512cd -target-feature -avx512dq -target-feature -avx512er -target-feature -avx512f -target-feature -avx512fp16 -target-feature -avx512ifma -target-feature -avx512pf -target-feature -avx512vbmi -target-feature -avx512vbmi2 -target-feature -avx512vl -target-feature -avx512vnni -target-feature -avx512vp2intersect -target-feature -avx512vpopcntdq -target-feature -avxvnni -target-feature -bmi -target-feature -bmi2 -target-feature -branchfusion -target-feature -cldemote -target-feature -clflushopt -target-feature -clwb -target-feature -clzero -target-feature +cmov -target-feature +crc32 -target-feature +cx16 -target-feature +cx8 -target-feature -enqcmd -target-feature -ermsb -target-feature -f16c -target-feature -false-deps-getmant -target-feature -false-deps-lzcnt-tzcnt -target-feature -false-deps-mulc -target-feature -false-deps-mullq -target-feature -false-deps-perm -target-feature +false-deps-popcnt -target-feature -false-deps-range -target-feature -fast-11bytenop -target-feature +fast-15bytenop -target-feature -fast-7bytenop -target-feature -fast-bextr -target-feature -fast-gather -target-feature -fast-hops -target-feature -fast-lzcnt -target-feature -fast-movbe -target-feature +fast-scalar-fsqrt -target-feature -fast-scalar-shift-masks -target-feature +fast-shld-rotate -target-feature -fast-variable-crosslane-shuffle -target-feature -fast-variable-perlane-shuffle -target-feature -fast-vector-fsqrt -target-feature -fast-vector-shift-masks -target-feature -fma -target-feature -fma4 -target-feature -fsgsbase -target-feature -fsrm -target-feature +fxsr -target-feature -gfni -target-feature -harden-sls-ijmp -target-feature -harden-sls-ret -target-feature -hreset -target-feature -idivl-to-divb -target-feature +idivq-to-divl -target-feature -invpcid -target-feature -kl -target-feature -lea-sp -target-feature -lea-uses-ag -target-feature -lvi-cfi -target-feature -lvi-load-hardening -target-feature -lwp -target-feature -lzcnt -target-feature +macrofusion -target-feature +mmx -target-feature -movbe -target-feature -movdir64b -target-feature -movdiri -target-feature -mwaitx -target-feature +nopl -target-feature -pad-short-functions -target-feature +pclmul -target-feature -pconfig -target-feature -pku -target-feature +popcnt -target-feature -prefer-128-bit -target-feature -prefer-256-bit -target-feature -prefer-mask-registers -target-feature -prefetchwt1 -target-feature -prfchw -target-feature -ptwrite -target-feature -rdpid -target-feature -rdpru -target-feature -rdrnd -target-feature -rdseed -target-feature -retpoline -target-feature -retpoline-external-thunk -target-feature -retpoline-indirect-branches -target-feature -retpoline-indirect-calls -target-feature -rtm -target-feature +sahf -target-feature -sbb-dep-breaking -target-feature -serialize -target-feature -seses -target-feature -sgx -target-feature -sha -target-feature -shstk -target-feature +slow-3ops-lea -target-feature -slow-incdec -target-feature -slow-lea -target-feature -slow-pmaddwd -target-feature -slow-pmulld -target-feature -slow-shld -target-feature -slow-two-mem-ops -target-feature -slow-unaligned-mem-16 -target-feature +slow-unaligned-mem-32 -target-feature -soft-float -target-feature +sse -target-feature +sse2 -target-feature +sse3 -target-feature +sse4.1 -target-feature +sse4.2 -target-feature -sse4a -target-feature -sse-unaligned-mem -target-feature +ssse3 -target-feature -tagged-globals -target-feature -tbm -target-feature -tsxldtrk -target-feature -uintr -target-feature -use-glm-div-sqrt-costs -target-feature -use-slm-arith-costs -target-feature -vaes -target-feature -vpclmulqdq -target-feature +vzeroupper -target-feature -waitpkg -target-feature -wbnoinvd -target-feature -widekl -target-feature +x87 -target-feature -xop -target-feature +xsave -target-feature -xsavec -target-feature +xsaveopt -target-feature -xsaves -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/detlef/.cache/zig/tmp/230410e59e289cc-helloworld.o -x c helloworld.c clang -cc1 version 15.0.0 based upon LLVM 15.0.0 default target x86_64-linux-musl ignoring duplicate directory "/usr/include" #include "..." search starts here: #include <...> search starts here: /data/_v/zig-linux-x86_64-0.10.0-dev.4369+1087e6776/lib/include /usr/include /usr/local/include /usr/include/x86_64-linux-gnu End of search list. LLD Link... ld.lld --error-limit=0 -O0 -z stack-size=16777216 --gc-sections --eh-frame-hdr -znow -m elf_x86_64 -o helloworld_zig_cc pwd: /_s/crt1.o pwd: /_s/crti.o -L /usr/local/lib64 -L /usr/local/lib -L /usr/lib/x86_64-linux-gnu -L /lib64 -L /lib -L /usr/lib64 -L /usr/lib -L /lib/x86_64-linux-gnu -L pwd: /_s -dynamic-linker /lib64/ld-linux-x86-64.so.2 /home/detlef/.cache/zig/o/7bcc982af050a066f8eec35097f18e82/helloworld.o /home/detlef/.cache/zig/o/e995a15b904612500827618e211001ee/libcompiler_rt.a --as-needed -lm -lpthread -lc -ldl -lrt -lutil pwd: /_s/crtn.o ld.lld: error: cannot open pwd: /_s/crt1.o: No such file or directory ld.lld: error: cannot open pwd: /_s/crti.o: No such file or directory ld.lld: error: cannot open pwd: /_s/crtn.o: No such file or directory
zig is not self compiled and not installed here:
- download the prebuild archiv
- unpack the archiv
- create a link for the zig directory:
ln -s zig-linux-x86_64-0.10.0-dev.4369+1087e6776 zig - use it, as described above
Sorry, i'm away from my laptop until next friday
there's so much going on there obv "pwd: /_s/" is not a valid path symlink different toolchains
any idea why it goes from
Target: x86_64-unknown-linux-gnu
...
"/data/_v/zig-linux-x86_64-0.10.0-dev.4369+1087e6776/zig" -cc1 -triple x86_64-unknown-linux-gnu ...
to
clang -cc1 version 15.0.0 based upon LLVM 15.0.0 default target x86_64-linux-musl
there's so much going on there obv "pwd: /_s/" is not a valid path symlink
/_s/ is a valid path on my system. Important thing is. while my pwd was /_s/hello/ and i tried to compile helloworld.c (full path: /-s/hello/helloworld.c), zig tried to find the crt startup files in the parrent directory of the current directory.
Using a subdirectory as build directory, zig was again searching the crt startup files in the parrent directory of the new build directory. (pwd: /_s/hello/_bin.zig/ zig wants to use /_s/hello/crt*.o)
different toolchains
any idea why it goes from
Target: x86_64-unknown-linux-gnu ... "/data/_v/zig-linux-x86_64-0.10.0-dev.4369+1087e6776/zig" -cc1 -triple x86_64-unknown-linux-gnu ...to
clang -cc1 version 15.0.0 based upon LLVM 15.0.0 default target x86_64-linux-musl
No Idea.
Where can i find a list of the daily builds for a regression test?
Searching regression:
Failing binary revisions 4326: same failure as in this bug report 4248: same failure as in this bug report 4240: same failure as in this bug report 4187: same failure as in this bug report 4136: same failure as in this bug report 4091: same failure as in this bug report 4056: same failure as in this bug report
3986: same failure as in this bug report 3984: same failure as in this bug report: /_s/hello$ zig cc helloworld.c -o helloworld_zig_3984 LLD Link... ld.lld: error: cannot open pwd: /_s/crt1.o: No such file or directory ld.lld: error: cannot open pwd: /_s/crti.o: No such file or directory ld.lld: error: cannot open pwd: /_s/crtn.o: No such file or directory
3981: different failure: zig cc helloworld.c -o helloworld_zig_3981 error: zig does not yet provide glibc version 2.35, the max provided version is 2.34 error: unable to build glibc shared objects: InvalidTargetGLibCVersion
failure changed between rev. 3981 and 3984 broken search path for the libc startup files
3962: same failure as 3981 3952: same failure as 3981
3944: works
regression one detected between rev. 3944 and 3952: InvalidTargetGLibCVersion: error: zig does not yet provide glibc version 2.35, the max provided version is 2.34 error: unable to build glibc shared objects: InvalidTargetGLibCVersion
################################
Attached is a script, which i created to download available binary releases.
starting point for every commit is: rev_last download trials: rev_tests when no revision+commit_id is downloadable, increase rev_tests max. required value detected between 4056 and 3999
What system are you running this command on?
What system are you running this command on?
xubuntu 22.04.1 LTS
Still present in zig 0.10 release:
/somewhere/hello$ zig cc helloworld.c -o helloworld_zig_cc_0.10_release LLD Link... ld.lld: error: cannot open pwd: /somewhere/crt1.o: No such file or directory ld.lld: error: cannot open pwd: /somewhere/crti.o: No such file or directory ld.lld: error: cannot open pwd: /somewhere/crtn.o: No such file or directory
I tried with latest downloadable binary and different values for -O and -target: -target makes a difference:
this fails: $ zig cc helloworld.c -Os -o helloworld_zig_cc_thrunk $ zig cc helloworld.c -o helloworld_zig_cc_thrunk
this both works: $ zig cc -target x86_64-linux-gnu helloworld.c -Os -o helloworld_zig_cc_thrunk_gnu $ zig cc -target x86_64-linux-gnu helloworld.c -o helloworld_zig_cc_thrunk_gnu
this both works: $ zig cc -target x86_64-linux-musl helloworld.c -Os -o helloworld_zig_cc_thrunk_musl $ zig cc -target x86_64-linux-musl helloworld.c -o helloworld_zig_cc_thrunk_musl
Hope, that helps. $ zig version 0.11.0-dev.486+19dd6de18
any idea why it goes from
Target: x86_64-unknown-linux-gnu ... "/data/_v/zig-linux-x86_64-0.10.0-dev.4369+1087e6776/zig" -cc1 -triple x86_64-unknown-linux-gnu ...to
clang -cc1 version 15.0.0 based upon LLVM 15.0.0 default target x86_64-linux-musl
There must be something wrong with the toolchain auto detection.
Probably zig fails to remember, which target libc/toolchain the autodetection selected (gnu libc in my case) in an early code stage, and later, when the target libc/toolchain is needed again, zig does another autodetection and pick a different target libc/toolchain (musl libc in my case)
My tests from 4.december ( https://github.com/ziglang/zig/issues/13185#issuecomment-1336523723 ) seems to prove that: Specify a -target, when using "zig cc" produces always a working executable for the selected libc/toolchain.
does your env show any results for:
env | grep pwd
is this steal a problem? tested on the latest zig realease 0.13.0 and it worked? (linux fedora)
It works on my current system.
Unfortunately, the old system is no longer in use.