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

[Bug] Compilation/linking error: arm-none-eabi, undefined reference to _exit / _kill / _getpid #10902

Closed
timvisee opened this issue Nov 9, 2020 · 17 comments · Fixed by #11573

Comments

@timvisee
Copy link

timvisee commented Nov 9, 2020

Describe the Bug

I'm getting an error during compilation/linking. My qmk installation is up-to-date as far as I can see, and my system is up-to-date as well.

$ ~/.local/bin/qmk compile
Ψ Compiling keymap with gmake ergodox_infinity:timvisee


QMK Firmware 0.10.50
Making ergodox_infinity with keymap timvisee

arm-none-eabi-gcc (15:9-2019-q4-0ubuntu1) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Compiling: keyboards/ergodox_infinity/keymaps/timvisee/keymap.c                                     [OK]
Compiling: quantum/process_keycode/process_terminal.c                                               [OK]
Compiling: tmk_core/common/command.c                                                                [OK]
Linking: .build/ergodox_infinity_timvisee.elf                                                       [ERRORS]
 |
 | /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/lib/thumb/v7e-m/nofp/libg.a(lib_a-abort.o): in function `abort':
 | /build/newlib-CVVEyx/newlib-3.3.0/build/arm-none-eabi/thumb/v7e-m/nofp/newlib/libc/stdlib/../../../../../../../../newlib/libc/stdlib/abort.c:59: undefined reference to `_exit'
 | /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/lib/thumb/v7e-m/nofp/libg.a(lib_a-signalr.o): in function `_kill_r':
 | /build/newlib-CVVEyx/newlib-3.3.0/build/arm-none-eabi/thumb/v7e-m/nofp/newlib/libc/reent/../../../../../../../../newlib/libc/reent/signalr.c:53: undefined reference to `_kill'
 | /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/bin/ld: /usr/lib/gcc/arm-none-eabi/9.2.1/../../../arm-none-eabi/lib/thumb/v7e-m/nofp/libg.a(lib_a-signalr.o): in function `_getpid_r':
 | /build/newlib-CVVEyx/newlib-3.3.0/build/arm-none-eabi/thumb/v7e-m/nofp/newlib/libc/reent/../../../../../../../../newlib/libc/reent/signalr.c:83: undefined reference to `_getpid'
 | collect2: error: ld returned 1 exit status
 |
gmake[1]: *** [tmk_core/rules.mk:306: .build/ergodox_infinity_timvisee.elf] Error 1
Make finished with errors
gmake: *** [Makefile:584: ergodox_infinity:timvisee] Error 1

Any ideas what is going on?

System Information

  • Keyboard: Ergodox Infinity
  • Operating system: Ubuntu 20.10
  • AVR GCC version: 5.4.0
  • ARM GCC version: arm-none-eabi-gcc (15:9-2019-q4-0ubuntu1) 9.2.1 20191025 (release) [ARM/arm-9-branch revision 277599]
  • QMK Firmware version: 0.10.50

Additional Context

This seems related: #9309

@timvisee timvisee changed the title [Bug] [Bug] Compilation/linking error: arm-none-eabi, undefined reference to _exit / _kill_r / _getpid_r Nov 9, 2020
@timvisee timvisee changed the title [Bug] Compilation/linking error: arm-none-eabi, undefined reference to _exit / _kill_r / _getpid_r [Bug] Compilation/linking error: arm-none-eabi, undefined reference to _exit / _kill / _getpid Nov 9, 2020
@timvisee
Copy link
Author

timvisee commented Nov 9, 2020

I do get warnings for missing udev rules, but I don't think that is relevant for this issue.

$ qmk setup
Ψ Found qmk_firmware at /home/timvisee/git/timvisee-qmk_firmware.

Would you like to set /home/timvisee/git/timvisee-qmk_firmware as your QMK home? [y/n] y

Ψ Wrote configuration to /home/timvisee/.config/qmk/qmk.ini
Ψ QMK Doctor is checking your environment.
Ψ Detected Linux.
⚠ Missing udev rules for 'atmel-dfu' boards. See https://docs.qmk.fm/#/faq_build?id=linux-udev-rules for more details.
⚠ Missing udev rules for 'kiibohd' boards. See https://docs.qmk.fm/#/faq_build?id=linux-udev-rules for more details.
⚠ Missing udev rules for 'stm32' boards. See https://docs.qmk.fm/#/faq_build?id=linux-udev-rules for more details.
⚠ Missing udev rules for 'bootloadhid' boards. See https://docs.qmk.fm/#/faq_build?id=linux-udev-rules for more details.
⚠ Missing udev rules for 'usbasploader' boards. See https://docs.qmk.fm/#/faq_build?id=linux-udev-rules for more details.
⚠ Missing udev rules for 'massdrop' boards. See https://docs.qmk.fm/#/faq_build?id=linux-udev-rules for more details.
⚠ Detected ModemManager without the necessary udev rules. Please either disable it or set the appropriate udev rules if you are using a Pro Micro.
⚠ Missing udev rules for 'caterina' boards. See https://docs.qmk.fm/#/faq_build?id=linux-udev-rules for more details.
Ψ QMK home: /home/timvisee/git/timvisee-qmk_firmware
Ψ All dependencies are installed.
Ψ Found arm-none-eabi-gcc version 9.2.1
Ψ Found avr-gcc version 5.4.0
Ψ Found avrdude version 6.3-20171130
Ψ Found dfu-util version 0.9
Ψ Found dfu-programmer version 0.6.1
Ψ Submodules are up to date.
Ψ Problems detected, please fix these problems before proceeding.

@DerGeist
Copy link

DerGeist commented Jan 3, 2021

I got the same problem for another keyboard, but I could solve it. Simple set CONSOLE_ENABLE = yes and it compiled fine for me.

@timvisee
Copy link
Author

timvisee commented Jan 3, 2021

I got the same problem for another keyboard, but I could solve it. Simple set CONSOLE_ENABLE = yes and it compiled fine for me.

This doesn't seem to solve it for me, sadly. I keep getting the same error.

@DerGeist
Copy link

DerGeist commented Jan 3, 2021

I tried it on QMK version 0.11.3 and the default layout compiled fine for me. Do you have the most recent version?

@timvisee
Copy link
Author

timvisee commented Jan 3, 2021

I tried it on QMK version 0.11.3 and the default layout compiled fine for me. Do you have the most recent version?

Still doesn't seem to work, unless I'm missing something. This is version 0.11.38.

Here's a recording: https://asciinema.org/a/2PRRXrCnNGR0vTEwk4OwnukFD

@tzarc
Copy link
Member

tzarc commented Jan 3, 2021

Have you got your code floating around on github somewhere?
Last I saw of this, someone was using malloc/free etc. in their code, which seems to be pulling in code related to syscalls.

@timvisee
Copy link
Author

timvisee commented Jan 3, 2021

It's available at my fork on https://github.com/timvisee/qmk_firmware/. I'm on the user-timvisee branch.

git clone https://github.com/timvisee/qmk_firmware.git qmk-timvisee
cd qmk-timvisee
git checkout user-timvisee

The keymap I'm using is at keyboards/ergodox_infinity/keymaps/timvisee/keymap.c.

@DerGeist
Copy link

DerGeist commented Jan 4, 2021

I have tested it with your fork. After changing CONSOLE_ENABLE = yes to no in the keyboards rules.mk the build worked fine for me. Compiler version: 10.2.0 on Manjaro. It seems to be caused by defining NO_PRINT in combination with TERMINAL_ENABLE = yes. Same for my compile on the ZSA fork which uses QMK Firmware 19 AUTO_SHIFT_ENABLE = yes and NO_PRINT defined. Same thing happens for your build when autoshift is enabled.

@timvisee
Copy link
Author

timvisee commented Jan 4, 2021

@DerGeist Thanks. It appears I set TERMINAL_ENABLE for Ergodox Infinity keyboards to true a year back. Removing this line to disable the feature fixed the compilation. At least I'm able to flash my keyboard now!

Changing CONSOLE_ENABLE does not seem to affect the compilation for me.

This does still seem like it is a bug though. I might open a new issue for this specific issue (the compilation failure for Ergodox Infinity with TERMINAL_ENABLE set).

@julowe
Copy link

julowe commented Jan 4, 2021

Similar error codes when trying to compile cKeys' Handwire101 keyboard. Removing TERMINAL_ENABLE (and associated terminal layer/keys) made it compile for me.

Though just running make ckeys/handwire_101:default EXTRAFLAGS+=--specs=nosys.specs (without making any changes to files in repo) also made it compile.

I'm not going in depth to actually fix this, as it works enough for me now - but figured I'd add any info to this issue to help you or future peoples.

@DerGeist
Copy link

DerGeist commented Jan 5, 2021

Same thing for the Moonlder and Planck compiling on the ZSA fork when TERMINAL_ENABLE or AUTO_SHIFT_ENABLE but in my case only if NO_PRINT is defined. In my case by setting COMMAND_ENABLE = no.

@taotien
Copy link

taotien commented Jan 10, 2021

The flags in rules file is what worked for me!

@ridingqwerty
Copy link
Contributor

@timvisee I just encountered this on a fresh Gentoo install. Although it took a little elbow grease to get the toolchain working to compile any ARM keymaps without linkage errors related to hard/soft float, it was working until I added my fork.

Re: what @tzarc said, I have a silly TESTING macro that utilizes malloc/free to snprintf some arbitrary string or float value. As soon as I comment this out, it builds fine.

Re: what @julowe said, if I leave the malloc/free code in, it builds fine with EXTRAFLAGS+=--specs=nosys.specs.

I've chosen to just leave it commented out for now as it's just not that important to me. I'm not sure that anything changed recently as I am able to build malloc/free code just find on another computer without needing to use EXTRAFLAGS.

None of the other rules.mk suggestions made any difference for me (COMMAND, CONSOLE, etc are already disabled).

Sorry if none of this is useful to you.

@taotien
Copy link

taotien commented Jan 11, 2021

Today I tried compiling with just CONSOLE_ENABLE = no commented out and it worked. Unknown if it's related but my program launcher script that relies on RAW_ENABLE stopped working, but also could be bad code because I made a lot of changes...

Edit: RAW_ENABLE still works, just the program on desktop-side stopped working

@tzarc
Copy link
Member

tzarc commented Jan 16, 2021

Would be great if people striking this issue can have a go with #11573 applied.
Compilation should succeed, currently untested on hardware -- would be great to hear if it's successful.

It's currently targeting ARM builds using ChibiOS as the HAL -- I don't have a newer AVR setup to validate any sort of failures.

@julowe
Copy link

julowe commented Jan 17, 2021

Works for me!

For completeness:
Completely separate/new checkout of repo, pulled your pr, ran make git-submodule, then make ckeys/handwire_101:default CTPC=yes, flashed new bin to hardware and it worked.

NB: And yes, make ckeys/handwire_101:default CTPC=yes still fails on master branch of repo

@tzarc tzarc linked a pull request Jan 17, 2021 that will close this issue
14 tasks
@tzarc
Copy link
Member

tzarc commented Jan 17, 2021

Should now be fixed on master branch.

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

Successfully merging a pull request may close this issue.

6 participants