Issue 128643
Summary [libc] Link error in libc overlay mode
Labels libc
Assignees
Reporter jun-shibata
    I linked a static archive (libllvmlibc.a) in the overlay mode of libc and built the code containing fileno.

```c
#include <stdio.h>
int main(int argc, char *argv[]) {
  return fileno(stderr);
}
```

Then a following link error occurred.

```script
$ clang a.c -L lib/libllvmlibc.a -lllvmlibc

/usr/bin/ld: lib/aarch64-unknown-linux-gnu/libllvmlibc.a(file.cpp.o): in function `__llvm_libc_21_0_0_git::RawMutex::lock_slow(__llvm_libc_21_0_0_git::cpp::optional<__llvm_libc_21_0_0_git::internal::AbsTimeout>, bool, unsigned int)':
file.cpp:(.text._ZN22__llvm_libc_21_0_0_git8RawMutex9lock_slowENS_3cpp8optionalINS_8internal10AbsTimeoutEEEbj[_ZN22__llvm_libc_21_0_0_git8RawMutex9lock_slowENS_3cpp8optionalINS_8internal10AbsTimeoutEEEbj]+0xb8): undefined reference to `__llvm_libc_21_0_0_git::internal::clock_gettime(int, timespec*)'
/usr/bin/ld: file.cpp:(.text._ZN22__llvm_libc_21_0_0_git8RawMutex9lock_slowENS_3cpp8optionalINS_8internal10AbsTimeoutEEEbj[_ZN22__llvm_libc_21_0_0_git8RawMutex9lock_slowENS_3cpp8optionalINS_8internal10AbsTimeoutEEEbj]+0xc4): undefined reference to `__llvm_libc_21_0_0_git::internal::clock_gettime(int, timespec*)'
/usr/bin/ld: a.out: hidden symbol `_ZN22__llvm_libc_21_0_0_git8internal13clock_gettimeEiP8timespec' isn't defined
/usr/bin/ld: final link failed: bad value
clang: error: linker command failed with exit code 1 (use -v to see invocation)
```

I used libc for AArch64 that was built followed official manual.
https://libc.llvm.org/overlay_mode.html#building-the-static-archive-as-part-of-the-bootstrap-build

llvm-project: a3dc77c00a012bb613cb08e669dab4fadf88e935
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to