Odin icon indicating copy to clipboard operation
Odin copied to clipboard

'atomic' header not found when comiling Odin

Open max22- opened this issue 10 months ago • 4 comments

Context

I can't manage to compile Odin on Debian testing (Trixie), on a x86_64. But when I compile it inside a docker image (based on the same distribution) it works.

I've tried with llvm-17 and llvm-14, still the same. I've also installed libx32stdc++-12-dev, as stated on the Getting Started page.

  • Operating System & Odin Version: Debian testing (trixie), Odin commit id 8899f4247 ( also retried with 510574aa7 )
  • Please paste odin report output:

generated from the version i built with the docker image :

Odin:    dev-2024-03:8899f4247
OS:      Debian GNU/Linux trixie/sid, Linux 6.6.15-amd64
CPU:     12th Gen Intel(R) Core(TM) i7-12700F
RAM:     15857 MiB
Backend: LLVM 17.0.6

Expected Behavior

It should compile.

Current Behavior

It doesn't find the "atomic" c++ header.

Failure Information (for bugs)

Steps to Reproduce

I can't reproduce it since it works inside docker, with the same distribution. Dockerfile used : Dockerfile.txt

Failure Logs

$ make
./build_odin.sh debug
+ clang++ src/main.cpp src/libtommath.cpp -Wno-switch -Wno-macro-redefined -Wno-unused-value -DODIN_VERSION_RAW="dev-2024-04" -DGIT_SHA="510574aa7" -std=c++14 -I/usr/lib/llvm-17/include -std=c++17 -fno-exceptions -funwind-tables -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -L/usr/lib/llvm-17/lib -g -pthread -lm -lstdc++ -ldl /usr/lib/llvm-17/lib/libLLVM-17.so -Wl,-rpath=$ORIGIN -o odin
In file included from src/main.cpp:2:
src/common.cpp:30:10: fatal error: 'atomic' file not found
#include <atomic> // Because I wanted the C++11 memory order semantics, of which gb.h does not offer (because it was a C89 library)
         ^~~~~~~~

max22- avatar Apr 04 '24 20:04 max22-

Looks like a typo on the "Getting Started" page. The package you're actually looking for is libstdc++-12-dev, i.e. without the "x32" in the name.

refual avatar Apr 23 '24 17:04 refual

this package is already installed on my system but it still doesn't work :( i've checked where the atomic header is located in the docker image : /usr/include/c++/13/atomic It is present at the same location on my linux distro, i don't understand... it's not a big deal for me because i can use the version i've built using docker, but it could maybe be useful to find the reason for other users ?

max22- avatar Apr 23 '24 19:04 max22-

I've had the same issue on Mint. I fix it by installing libc++-dev and g++-12.

jimhub avatar Apr 26 '24 02:04 jimhub

this package is already installed on my system but it still doesn't work :( i've checked where the atomic header is located in the docker image : /usr/include/c++/13/atomic It is present at the same location on my linux distro, i don't understand...

Looking into it some more it seems you should run clang++ -v to find out which version of GCC it wants to use and install the corresponding libstd++-dev package for that. On my system (Ubuntu 22.04) that was version 12:

$ clang++ -v
...
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/11
Found candidate GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12
Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/12

Note that this is indeed gcc-12 and not g++-12 as I don't have g++-12 installed on my system and I can build the compiler just fine.

refual avatar Apr 28 '24 11:04 refual

clang++ -v returned this :

Selected GCC installation: /usr/bin/../lib/gcc/x86_64-linux-gnu/14

I installed libstdc++-14-dev, and now it works, thank you !!

max22- avatar Apr 29 '24 21:04 max22-

Hello,

In Linux OpenSuse Tumbleweed with LLVM 18, if it gives us the following error:

In file included from src/main.cpp:2:
src/common.cpp:30:10: fatal error: 'atomic' file not found
   30 | #include <atomic> // Because I wanted the C++11 memory order semantics, of which gb.h does not offer (because it was a C89 library)
      |          ^~~~~~~~
1 error generated.
make: *** [Makefile:10: debug] Error 1

We have to issue the following command

clang++ -v
(base) joaocarvalho@soundofsilence:~/odin/Odin> clang++ -v
clang version 18.1.5
Target: x86_64-suse-linux
Thread model: posix
InstalledDir: /usr/bin
System configuration file directory: /etc/clang
User configuration file directory: /home/joaocarvalho/.config/clang
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-suse-linux/12
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-suse-linux/13
Found candidate GCC installation: /usr/bin/../lib64/gcc/x86_64-suse-linux/14
Selected GCC installation: /usr/bin/../lib64/gcc/x86_64-suse-linux/14
Candidate multilib: .;@m64
Selected multilib: .;@m64

We then see that it is the gcc 14 that is in use by clang++ and then we have to install the corresponding gcc version of the libstdc++ :

OpenSuse Tumbleweed compilation of Odin with llvm 18 I had to install:

libstdc++6-devel-gcc14

do:

sudo zypper install libstdc++6-devel-gcc14

then do again:

make

Note: This was made ( solved ) according the current thread and from the help of Jason and Layton:

'atomic' header not found when comiling Odin #3376 https://github.com/odin-lang/Odin/issues/3376

Thank you very much Jason, and thank you very much Laytan!

Best regards,

joaocarvalhoopen avatar May 19 '24 13:05 joaocarvalhoopen