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

undefined LFS64 symbols on musl 1.2.4 #15610

Closed
12101111 opened this issue May 7, 2023 · 4 comments
Closed

undefined LFS64 symbols on musl 1.2.4 #15610

12101111 opened this issue May 7, 2023 · 4 comments
Labels
bug Observed behavior contradicts documented or intended behavior os-linux
Milestone

Comments

@12101111
Copy link

12101111 commented May 7, 2023

Zig Version

0.10.1

Steps to Reproduce and Observed Behavior

musl 1.2.4 remove those symbols: https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4

zig compiler failed to link on musl 1.2.4:

ld.lld: error: undefined symbol: fstat64
>>> referenced by os.zig:4142 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:4142)
>>>               zig2.o:(std.os.fstat)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_48097)

ld.lld: error: undefined symbol: ftruncate64
>>> referenced by os.zig:912 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:912)
>>>               zig2.o:(std.os.ftruncate)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_48168)

ld.lld: error: undefined symbol: getrlimit64
>>> referenced by os.zig:6973 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:6973)
>>>               zig2.o:(std.os.getrlimit)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_48333)

ld.lld: error: undefined symbol: setrlimit64
>>> referenced by os.zig:6989 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:6989)
>>>               zig2.o:(std.os.setrlimit)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_48334)

ld.lld: error: undefined symbol: mmap64
>>> referenced by os.zig:4427 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:4427)
>>>               zig2.o:(std.os.mmap)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_48223)

ld.lld: error: undefined symbol: openat64
>>> referenced by os.zig:1728 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:1728)
>>>               zig2.o:(std.os.openatZ)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_49886)

ld.lld: error: undefined symbol: pwrite64
>>> referenced by os.zig:1251 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:1251)
>>>               zig2.o:(std.os.pwrite)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_50070)

ld.lld: error: undefined symbol: pwritev64
>>> referenced by os.zig:1340 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:1340)
>>>               zig2.o:(std.os.pwritev)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_51858)

ld.lld: error: undefined symbol: sendfile64
>>> referenced by os.zig:6145 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:6145)
>>>               zig2.o:(std.os.sendfile)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_51877)

ld.lld: error: undefined symbol: pread64
>>> referenced by os.zig:837 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:837)
>>>               zig2.o:(std.os.pread)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_52433)

ld.lld: error: undefined symbol: open64
>>> referenced by os.zig:1451 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:1451)
>>>               zig2.o:(std.os.openZ)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_53151)

ld.lld: error: undefined symbol: lseek64
>>> referenced by os.zig:4844 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:4844)
>>>               zig2.o:(std.os.lseek_SET)
>>> referenced by os.zig:4984 (/tmp/portage/dev-lang/zig-0.10.1-r2/work/zig-0.10.1/lib/std/os.zig:4984)
>>>               zig2.o:(std.os.lseek_CUR_get)
>>> referenced by zig2
>>>               zig2.o:(__unnamed_55067)
>>> referenced 1 more times
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)

Expected Behavior

std should use symbols without 64 suffix on musl target

@12101111 12101111 added the bug Observed behavior contradicts documented or intended behavior label May 7, 2023
@LinuxUserGD
Copy link
Contributor

Should be fixed by #16098

@ifreund
Copy link
Member

ifreund commented Jul 17, 2023

musl 1.2.4 remove those symbols: https://git.musl-libc.org/cgit/musl/commit/?id=246f1c811448f37a44b41cd8df8d0ef9736d95f4

From that commit it looks like the workaround implemented in musl's dynamic linker does not work for zig since zig uses it's own lld copy to link on linux.

@andrewrk andrewrk added this to the 0.12.0 milestone Jul 23, 2023
@reubenmiller
Copy link

I also experienced a similar error using ziglang 0.11.0 (released today), where as rolling back to ziglang 0.10.1 then everything works again.

Below shows an example of the error that we experienced when we build a rust project via cargo-zigbuild.

   Compiling c8y-device-management v0.12.0 (/Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/crates/bin/c8y-device-management)
error: linking with `/Users/reubenmiller/Library/Caches/cargo-zigbuild/0.17.0/zigcc-aarch64-unknown-linux-musl.sh` failed: exit status: 1
  |
  = note: LC_ALL="C" PATH="/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin:/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-apple-darwin/bin/self-contained:/Users/reubenmiller/homebrew/lib/python3.11/site-packages/ziglang:/Users/reubenmiller/.nvm/versions/node/v16.20.0/bin:/Users/reubenmiller/go/bin:/Users/reubenmiller/.gem/ruby/2.6.0/bin:/Users/reubenmiller/.local/bin:/Users/reubenmiller/homebrew/bin:/Users/reubenmiller/homebrew/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/local/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/bin:/var/run/com.apple.security.cryptexd/codex.system/bootstrap/usr/appleinternal/bin:/Users/reubenmiller/.nvm/versions/node/v16.20.0/bin:/Users/reubenmiller/go/bin:/Users/reubenmiller/.gem/ruby/2.6.0/bin:/Users/reubenmiller/.local/bin:/Users/reubenmiller/homebrew/bin:/Users/reubenmiller/homebrew/sbin:/Users/reubenmiller/.cargo/bin" VSLANG="1033" "/Users/reubenmiller/Library/Caches/cargo-zigbuild/0.17.0/zigcc-aarch64-unknown-linux-musl.sh" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crt1.o" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crti.o" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtbegin.o" "/var/folders/wn/06nj6dqj07db9tbsh_094wnr0000gn/T/rustcI76qPN/symbols.o" "/Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps/tedge_apt_plugin-7ab3b63bf7802a60.tedge_apt_plugin.83263cc3-cgu.0.rcgu.o" "-Wl,--as-needed" "-L" "/Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps" "-L" "/Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/release/deps" "-L" "/Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/build/ring-5f5de5359cbae5d7/out" "-L" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib" "-Wl,-Bstatic" "/var/folders/wn/06nj6dqj07db9tbsh_094wnr0000gn/T/rustcI76qPN/libring-d067ef4392861a30.rlib" "-lunwind" "-lc" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib/libcompiler_builtins-0a28d23d76fcec1d.rlib" "-Wl,-Bdynamic" "-Wl,--eh-frame-hdr" "-Wl,-znoexecstack" "-nostartfiles" "-L" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib" "-L" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained" "-o" "/Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps/tedge_apt_plugin-7ab3b63bf7802a60" "-Wl,--gc-sections" "-static" "-no-pie" "-Wl,-zrelro,-znow" "-Wl,--strip-all" "-nodefaultlibs" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtend.o" "/Users/reubenmiller/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/aarch64-unknown-linux-musl/lib/self-contained/crtn.o"
  = note: In file included from /Users/reubenmiller/homebrew/lib/python3.11/site-packages/ziglang/lib/libc/musl/crt/rcrt1.c:3:
          /Users/reubenmiller/homebrew/lib/python3.11/site-packages/ziglang/lib/libc/musl/crt/../ldso/dlstart.c:146:20: warning: a function declaration without a prototype is deprecated in all versions of C and is treated as a zero-parameter prototype in C2x, conflicting with a subsequent definition [-Wdeprecated-non-prototype]
                  GETFUNCSYM(&dls2, __dls2, base+dyn[DT_PLTGOT]);
                                    ^
          /Users/reubenmiller/homebrew/lib/python3.11/site-packages/ziglang/lib/libc/musl/crt/rcrt1.c:11:13: note: conflicting prototype is here
          hidden void __dls2(unsigned char *base, size_t *sp)
                      ^
          1 warning generated.
          ld.lld: error: undefined symbol: open64
          >>> referenced by fs.rs:1004 (library/std/src/sys/unix/fs.rs:1004)
          >>>               /Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps/tedge_apt_plugin-7ab3b63bf7802a60.tedge_apt_plugin.83263cc3-cgu.0.rcgu.o:(std::sys::unix::fs::File::open_c::h493afe1936ae47ca)
          
          ld.lld: error: undefined symbol: stat64
          >>> referenced by fs.rs:1496 (library/std/src/sys/unix/fs.rs:1496)
          >>>               /Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps/tedge_apt_plugin-7ab3b63bf7802a60.tedge_apt_plugin.83263cc3-cgu.0.rcgu.o:(std::fs::metadata::hcc0f835db18a4a95)
          >>> referenced by fs.rs:1496 (library/std/src/sys/unix/fs.rs:1496)
          >>>               /Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps/tedge_apt_plugin-7ab3b63bf7802a60.tedge_apt_plugin.83263cc3-cgu.0.rcgu.o:(std::sys::common::small_c_string::run_with_cstr_allocating::ha58afbeb569d08a2)
          >>> referenced by tedge_apt_plugin.83263cc3-cgu.0
          >>>               /Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps/tedge_apt_plugin-7ab3b63bf7802a60.tedge_apt_plugin.83263cc3-cgu.0.rcgu.o:(tedge_config::tedge_config_cli::tedge_config_repository::TEdgeConfigRepository::load_new::h6aa4e8f237b43231)
          
          ld.lld: error: undefined symbol: fstat64
          >>> referenced by fs.rs:1023 (library/std/src/sys/unix/fs.rs:1023)
          >>>               /Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps/tedge_apt_plugin-7ab3b63bf7802a60.tedge_apt_plugin.83263cc3-cgu.0.rcgu.o:(std::backtrace_rs::symbolize::gimli::mmap::h3a0eba89c5864f51)
          >>> referenced by fs.rs:1023 (library/std/src/sys/unix/fs.rs:1023)
          >>>               /Users/reubenmiller/dev/projects/tedge/code/fork-docs/thin-edge.io/target/aarch64-unknown-linux-musl/release/deps/tedge_apt_plugin-7ab3b63bf7802a60.tedge_apt_plugin.83263cc3-cgu.0.rcgu.o:(std::fs::read_to_string::inner::h188ccc3791ffa11d)     

@12101111
Copy link
Author

Fixed in #16098

@andrewrk andrewrk modified the milestones: 0.13.0, 0.12.0 Sep 25, 2023
michaeladler added a commit to michaeladler/wfx that referenced this issue Oct 26, 2023
This project does not compile with zig 0.11 (actually because of musl
1.2.4), see ziglang/zig#15610.

Signed-off-by: Michael Adler <michael.adler@siemens.com>
stormc pushed a commit to siemens/wfx that referenced this issue Oct 26, 2023
This project does not compile with zig 0.11 (actually because of musl
1.2.4), see ziglang/zig#15610.

Signed-off-by: Michael Adler <michael.adler@siemens.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior os-linux
Projects
None yet
Development

No branches or pull requests

5 participants