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

LD error: multiple definition of sinRoll when using gcc 10.2 #613

Closed
goekce opened this issue Aug 22, 2020 · 3 comments
Closed

LD error: multiple definition of sinRoll when using gcc 10.2 #613

goekce opened this issue Aug 22, 2020 · 3 comments
Milestone

Comments

@goekce
Copy link

goekce commented Aug 22, 2020

On Archlinux the compilation errors out with default config.mk:

git clone https://github.com/bitcraze/crazyflie-firmware --recursive
cd crazyflie-firmware
cp tools/make/config.mk.example tools/make/config.mk
make -j4
...
/usr/lib/gcc/arm-none-eabi/10.2.0/../../../../arm-none-eabi/bin/ld: bin/sensors_mpu9250_lps25h.o:/home/u/projects/crazyflie/crazyflie-firmware/.//src/hal/src/sensors_mpu9250_lps25h.c:154: multiple definition of `sinRoll'; bin/sensors_bmi088_bmp388.o:/home/u/projects/crazyflie/crazyflie-firmware/.//src/hal/src/sensors_bmi088_bmp388.c:149: first defined here
...
# same error for cosRoll, sinPitch, and cosPitch

I use gcc 10.2:

arm-none-eabi-gcc -v

Using built-in specs.
COLLECT_GCC=arm-none-eabi-gcc
COLLECT_LTO_WRAPPER=/usr/lib/gcc/arm-none-eabi/10.2.0/lto-wrapper
Target: arm-none-eabi
Configured with: /build/arm-none-eabi-gcc/src/gcc-10.2.0/configure --target=arm-none-eabi --prefix=/usr --with-sysroot=/usr/arm-none-eabi --with-native-system-header-dir=/include --libexecdir=/usr/lib --enable-languages=c,c++ --enable-plugins --disable-decimal-float --disable-libffi --disable-libgomp --disable-libmudflap --disable-libquadmath --disable-libssp --disable-libstdcxx-pch --disable-nls --disable-shared --disable-threads --disable-tls --with-gnu-as --with-gnu-ld --with-system-zlib --with-newlib --with-headers=/usr/arm-none-eabi/include --with-python-dir=share/gcc-arm-none-eabi --with-gmp --with-mpfr --with-mpc --with-isl --with-libelf --enable-gnu-indirect-function --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --with-pkgversion='Arch Repository' --with-bugurl=https://bugs.archlinux.org/ --with-multilib-list=rmprofile
Thread model: single
Supported LTO compression algorithms: zlib zstd
gcc version 10.2.0 (Arch Repository)

and:

arm-none-eabi-ld -v 
GNU ld (GNU Binutils) 2.34
@goekce
Copy link
Author

goekce commented Aug 22, 2020

A workaround is adding CFLAGS += -fcommon to config.mk

Apparently newer gcc is more strict about multiple definitions of global variables. The link below has some suggestions how to fix them. It boils down to using extern and declaring the global variables in a single file.

Thanks to: GazL's posting on linuxquestions.org

@goekce goekce changed the title LD error: multiple definition of sinRoll on Archlinux LD error: multiple definition of sinRoll when using gcc 10.2 Aug 22, 2020
@ataffanel
Copy link
Member

Hi, thanks for the report, this is an actual bug that the new GCC found. I pushed a fix by adding static to these variables since they are, as far as I could tell, local to the file. Could you compile again to see if it now compiles?

@goekce
Copy link
Author

goekce commented Aug 25, 2020

@ataffanel wauw thanks for the quick fix! lgtm

@goekce goekce closed this as completed Aug 25, 2020
@krichardsson krichardsson added this to the next-release milestone Aug 25, 2020
williamleong pushed a commit to TL-NUS-CFS/crazyflie-firmware that referenced this issue Oct 11, 2023
cafeciaojoe pushed a commit to cafeciaojoe/crazyflie-firmware that referenced this issue Sep 27, 2024
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

3 participants