rust-cross / cargo-zigbuild

Compile Cargo project with zig as linker
MIT License
1.55k stars 57 forks source link

glibc 2.27 or older: fcntl@GLIBC_2.2.5 not found when build for armv7 #143

Closed Dirreke closed 4 months ago

Dirreke commented 1 year ago

I created an Issue on zig, https://github.com/ziglang/zig/issues/16002 I get it when I build for armv7-unknown-linux-gnueabihf

  = 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

And 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

I noticed that cargo-zigbuild create fcntl.h and fcntl.map to help finish the compile. Therefore, I want to know if cargo-zigbuild know why and if cargo-zigbuild can solve this by adding some code to fcntl.h and fcntl.map