Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Failing to build on ARM due to missing atomic library #36371

Closed
nlw0 opened this issue Jun 20, 2020 · 10 comments
Closed

Failing to build on ARM due to missing atomic library #36371

nlw0 opened this issue Jun 20, 2020 · 10 comments

Comments

@nlw0
Copy link
Contributor

nlw0 commented Jun 20, 2020

I'm building Julia on a Raspberry Pi v4 (armv7l), and a linking step is failing due to a missing -latomic. If I copy the g++ command and add it, it seems to work, although I still couldn't carry out the complete build. I see there's some reference in it at the Makefile, though I cannot figure out how to test that. Could this be some problem in my system instead? How can I make this work?

@nlw0
Copy link
Contributor Author

nlw0 commented Jun 20, 2020

(...)
    CC src/llvm-multiversioning.o
    CC src/llvm-alloc-opt.o
    CC src/cgmemmgr.o
    CC src/llvm-api.o
    LINK usr/lib/libjulia.so.1.4
/usr/bin/ld: ./gc.o: in function `combine_thread_gc_counts':
/home/pi/src/julia/src/gc.c:998: undefined reference to `__atomic_load_8'
/usr/bin/ld: /home/pi/src/julia/src/gc.c:999: undefined reference to `__atomic_load_8'
/usr/bin/ld: /home/pi/src/julia/src/gc.c:1000: undefined reference to `__atomic_load_8'
/usr/bin/ld: /home/pi/src/julia/src/gc.c:1001: undefined reference to `__atomic_load_8'
/usr/bin/ld: /home/pi/src/julia/src/gc.c:1002: undefined reference to `__atomic_load_8'
/usr/bin/ld: ./gc.o:/home/pi/src/julia/src/gc.c:1003: more undefined references to `__atomic_load_8' follow
/usr/bin/ld: ./gc.o: in function `jl_gc_collect':
/home/pi/src/julia/src/gc.c:3076: undefined reference to `__atomic_fetch_add_8'
collect2: error: ld returned 1 exit status
make[1]: *** [Makefile:331: /home/pi/src/julia/usr/lib/libjulia.so.1.4] Error 1
make: *** [Makefile:75: julia-src-release] Error 2

@yuyichao
Copy link
Contributor

What is the target you are compiling for? I don't think you'll need these if you compile for armv7-a

@nlw0
Copy link
Contributor Author

nlw0 commented Jun 20, 2020

I'm just running make on the box itself, native. It worked with LDFLAGS=-latomic make... You mean we may have to change atomics.h instead of Makefile?

@yuyichao
Copy link
Contributor

No I'm saying if your compiler is compiling for armv7-a. I said nothing about atomic.h.

The thing to check is the default arch for your compiler, e.g. with gcc -dumpmachine and gcc -v -E - < /dev/null. You can also force it with -march=armv7-a.

@nlw0
Copy link
Contributor Author

nlw0 commented Jun 20, 2020

This is what I get... And lscpu says armv7l.

pi@raspberrypi:~ $ gcc -dumpmachine
arm-linux-gnueabihf
pi@raspberrypi:~ $ gcc -v -E - < /dev/null
Using built-in specs.
COLLECT_GCC=gcc
Target: arm-linux-gnueabihf
Configured with: ../src/configure -v --with-pkgversion='Raspbian 8.3.0-6+rpi1' --with-bugurl=file:///usr/share/doc/gcc-8/README.Bugs --enable-languages=c,ada,c++,go,d,fortran,objc,obj-c++ --prefix=/usr --with-gcc-major-version-only --program-suffix=-8 --program-prefix=arm-linux-gnueabihf- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --enable-bootstrap --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-libitm --disable-libquadmath --disable-libquadmath-support --enable-plugin --with-system-zlib --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --disable-sjlj-exceptions --with-arch=armv6 --with-fpu=vfp --with-float=hard --disable-werror --enable-checking=release --build=arm-linux-gnueabihf --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf
Thread model: posix
gcc version 8.3.0 (Raspbian 8.3.0-6+rpi1)
COLLECT_GCC_OPTIONS='-v' '-E'  '-mfloat-abi=hard' '-mfpu=vfp' '-mtls-dialect=gnu' '-marm' '-march=armv6+fp'
 /usr/lib/gcc/arm-linux-gnueabihf/8/cc1 -E -quiet -v -imultilib . -imultiarch arm-linux-gnueabihf - -mfloat-abi=hard -mfpu=vfp -mtls-dialect=gnu -marm -march=armv6+fp
ignoring nonexistent directory "/usr/local/include/arm-linux-gnueabihf"
ignoring nonexistent directory "/usr/lib/gcc/arm-linux-gnueabihf/8/../../../../arm-linux-gnueabihf/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/arm-linux-gnueabihf/8/include
 /usr/local/include
 /usr/lib/gcc/arm-linux-gnueabihf/8/include-fixed
 /usr/include/arm-linux-gnueabihf
 /usr/include
End of search list.
# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"
COMPILER_PATH=/usr/lib/gcc/arm-linux-gnueabihf/8/:/usr/lib/gcc/arm-linux-gnueabihf/8/:/usr/lib/gcc/arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/8/:/usr/lib/gcc/arm-linux-gnueabihf/
LIBRARY_PATH=/usr/lib/gcc/arm-linux-gnueabihf/8/:/usr/lib/gcc/arm-linux-gnueabihf/8/../../../arm-linux-gnueabihf/:/usr/lib/gcc/arm-linux-gnueabihf/8/../../../:/lib/arm-linux-gnueabihf/:/lib/:/usr/lib/arm-linux-gnueabihf/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-E'  '-mfloat-abi=hard' '-mfpu=vfp' '-mtls-dialect=gnu' '-marm' '-march=armv6+fp'

@yuyichao
Copy link
Contributor

You are not compiling for armv7-a. You need to set it.

@nlw0
Copy link
Contributor Author

nlw0 commented Jun 20, 2020

You talk as if I was doing something different than just cloning the project and running "make". Am I mistaken to hope this should work? I did manage to build and run it without setting the target, and I have to assume the people who put together my distro chose a suitable default.

I tried CXXFLAGS="-march=native" make as well, same problem. I'm going to stick with that, though, so thanks for pointing that out. It does not seem to solve the problem by itself, though.

@yuyichao
Copy link
Contributor

Am I mistaken to hope this should work?

Correct. Because your compiler was not configured for the machine you are running it on.

I have to assume the people who put together my distro chose a suitable default.

That may not be a good assumption.

CXXFLAGS="-march=native" make

You also need it for CFLAGS and you should set MARCH variable for make instead make MARCH=armv7-a.

@nlw0
Copy link
Contributor Author

nlw0 commented Jun 20, 2020

make MARCH=native works. Thanks!

I guess the problem has something to do with Raspbian not being a full 64-bit distro or something like that.

I'm just going to close this since it depends too much on the general weirdness of the Universe. Hope it might be useful to others.

@nlw0 nlw0 closed this as completed Jun 20, 2020
@yuyichao
Copy link
Contributor

armv7 is still 32bit. If I have to guess it's because they need to support old versioin of resperty pi hat's not v7.

To be clear, I think you are running a 32bit system on a 64bit hardware and the system is configured for armv6....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants