zig icon indicating copy to clipboard operation
zig copied to clipboard

undefined symbol: fcntl@GLIBC_2.2.5 when compile for armv7

Open Dirreke opened this issue 2 years ago • 6 comments

Zig Version

0.9.1

Steps to Reproduce and Observed Behavior

Sorry, I'm new to zig. If I'm wrong, please let me know. I'm trying use zig cc to compile rocksdb (actually I compile rust-rocksdb ) for armv7-linux-gnueabihf. zig 0.10.1 can not compile for armv7 with multiple thread, and according to #6573 , 0.9.1 can do it. So I use zig 0.9.1, and I get this when linking. It really confused me

  = note: ld.lld: error: undefined symbol: fcntl@GLIBC_2.2.5
          >>> referenced by fs_posix.cc:157 (rocksdb/env/fs_posix.cc:157)
          >>>               fs_posix.o:(rocksdb::(anonymous namespace)::PosixFileSystem::NewSequentialFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::FileOptions const&, std::__1::unique_ptr<rocksdb::FSSequentialFile, std::__1::default_delete<rocksdb::FSSequentialFile> >*, rocksdb::IODebugContext*)) in archive .../armv7-unknown-linux-gnueabihf/debug/deps/liblibrocksdb_sys-6aa47adaadf43187.rlib
          >>> referenced by fs_posix.cc:157 (rocksdb/env/fs_posix.cc:157)
          >>>               fs_posix.o:(rocksdb::(anonymous namespace)::PosixFileSystem::NewSequentialFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::FileOptions const&, std::__1::unique_ptr<rocksdb::FSSequentialFile, std::__1::default_delete<rocksdb::FSSequentialFile> >*, rocksdb::IODebugContext*)) in archive .../armv7-unknown-linux-gnueabihf/debug/deps/liblibrocksdb_sys-6aa47adaadf43187.rlib
          >>> referenced by fs_posix.cc:157 (rocksdb/env/fs_posix.cc:157)
          >>>               fs_posix.o:(rocksdb::(anonymous namespace)::PosixFileSystem::NewRandomAccessFile(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, rocksdb::FileOptions const&, std::__1::unique_ptr<rocksdb::FSRandomAccessFile, std::__1::default_delete<rocksdb::FSRandomAccessFile> >*, rocksdb::IODebugContext*)) in archive .../armv7-unknown-linux-gnueabihf/debug/deps/liblibrocksdb_sys-6aa47adaadf43187.rlib
          >>> referenced 12 more times
          >>> did you mean: fcntl
          >>> defined in: ~/.cache/zig/o/f9d9fcf846b561cef901d9b46b123fcc/libpthread.so.0

Does it mean that I can't compile it for arm anyway? Or Is there something special flags I need to pass in?

Expected Behavior

//

Dirreke avatar Jun 10 '23 19:06 Dirreke

armv7-linux-gnueabihf

Are you sure this is the correct target? Zig uses arm-linux for this I think.

Kuratius avatar Jun 10 '23 19:06 Kuratius

yeah, I use cargo-zigbuild to call zig, and it can set target to arm-linux correctly

Dirreke avatar Jun 10 '23 19:06 Dirreke

Possibly related: https://github.com/ziglang/zig/issues/5882, https://github.com/ziglang/zig/issues/9485

squeek502 avatar Jun 11 '23 04:06 squeek502

yeah, I noticed it too. However, even if I set target to arm-linux-gnueabihf.2.24, it's compiled failed either

Dirreke avatar Jun 11 '23 06:06 Dirreke

I do some investigating. I found that ~/.cache/zig/o/.../c.o has fcntl@GLIBC_2.4 but not fcntl@GLIBC_2.2.5. I don't know why

Dirreke avatar Jun 13 '23 12:06 Dirreke