Issue |
147401
|
Summary |
`clang -O` produces references to `memset` even with `-fno-builtin -ffreestanding -nostdlib`
|
Labels |
clang
|
Assignees |
|
Reporter |
attila-lendvai
|
i'm compiling a static linux binary that talks directly to the kernel, i.e. without libc:
`clang -O3 -nostdlib -nostartfiles -ffreestanding -fno-builtin-memset -Wl,-Bstatic -Qunused-arguments --target=x86_64-linux-gnu eval2.ll`
if i delete the `-O` then it works as expected.
i think some of the optimizations emits calls to `memset` regardless of the command line arguments.
```
$ clang --version
clang version 20.1.7
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /gnu/store/hvi2iz7n4zk4pyxvibrxa6j43hkv4wn2-clang-20.1.7/bin
```
```
$ uname -a
Linux lelap 6.14.11 #1 SMP PREEMPT_DYNAMIC 1 x86_64 GNU/Linux
$ guix describe
Generation 231 Jul 06 2025 13:09:57 (current)
guix 50b7528
repository URL: https://codeberg.org/guix/guix.git
branch: master
commit: 50b75285883623ee244d0a71a225807c0672ac33
```
[eval2.ll.gz](https://github.com/user-attachments/files/21110384/eval2.ll.gz)
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs