-
Notifications
You must be signed in to change notification settings - Fork 447
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
Segmentation fault on Serial.begin() #486
Comments
the arch package seems seriously broken its been noticed before, use git |
Thanks for the reply but that does not resolve the issue. I completely removed the AUR packages and cloned the git repo. The most simplistic case is provided by the "SerialPrint" example in the example folder of the repo. It produces the exact same error while other examples like the "Blink" example compile without any problems:
(That is of course the output of a second Edit: |
probably as you're using avr-gcc 6.3 instead of 4.9, seems like something to do with LTO support (which BAP doesn't have). |
@UsoHolger how did you install your version of avr-gcc? |
I am using the avr-gcc package from the official Arch software repository installed via Pacman. |
well I guess the best way would be to comment the different variables used in bare arduino project and let us know what causes the bug. |
I tested using the simplistic SerialPrint example. What does the trick is setting the 2011 standard flag. So this makefile
fails with the segmentation fault error while adding the line |
can i see your code? |
I used the SerialPrint example. So the code is:
with the makefile
|
its the LTO parts of CXXFLAGS_STD/CFLAGS_STD, changing them from https://github.com/sudar/Arduino-Makefile/blob/master/arduino-mk-vars.md#cflags_std i assume your avr-gcc hasn't been built with LTO support |
Yes, that's an issue with AVR. We are currently investigating the homebrew formula. I'll keep you posted. |
Hello, Just hitting this issue too, and google led me here. As suggested in osx-cross/homebrew-avr#46 (linked above), I can confirm adding: CFLAGS_STD = -std=gnu11 -flto -fno-fat-lto-objects to Makefile just make arduino-mk (freshly checked-out from github) compiling without segfault on Fedora 26 x86_64 with:
Hope this will be helpful. Cordially, -- |
@NVieville i'm a bit confused as these are set by default now in Arduino.mk
Removing LTO flags fixes things for > 4.9.0 compilers that don't have LTO support, but i'd have thought the f26 compilers do (otherwise report it as a bug as they also package IDE 1.6 which kind of requires it, although f26 is on 1.6.6 not 1.6.10 where LTO was added), what's the problem you're having? what does |
Hello, @sej7278 Thanks for your response, and sorry for not being quite explicit. I just tried your suggestion to remove the -flto flag, and compiling goes well. I just noticed that AVR Memory Usage information displayed at the end of the building process is a bit higher when removing the -flto flag than with keeping it and adding the -fno-devirtualize one. For information here is the output of the "avr-gcc -v" command on Fedora 26: Using built-in specs. My knowledge about this is not enough to say if it's worth removing -flto flag (no link time optimization) or keeping it and adding -fno-devirtualize one in such a configuration. Sorry again for not being quite explicit in my first message. -- |
how odd! so if adding the you should just be able to add this to your local Makefile:
|
Tha actual version of gcc in Fedora 26 is: gcc (GCC) 7.1.1 20170622 (Red Hat 7.1.1-3)
I tried your suggestion: adding Thanks for your explanations. -- |
sorry, should be CXXFLAGS, this works for me: BOARD_TAG = leonardo
MONITOR_PORT = /dev/ttyACM0
CXXFLAGS += -fno-devirtualize
include /usr/share/arduino/Arduino.mk not sure if any other flags need to be changed like CFLAGS or ASFLAGS. i'd say maybe we ought to add maybe we should move from querying the avr-gcc version: ifeq ($(shell expr $(CC_VERNUM) '>' 490), 1) to looking for LTO support instead:
i can't remember if we added the version check just for LTO or if it was for g++11 also. |
…s could impact performance we should track when the issue is fixed upstream to remove the flag again (see links from Issue sudar#486) Enabled colourised diagnostics from avr-gcc We forgot to increase ARDMK_VERSION for the 1.6.0 release
@sej7278 Thank you. About the gcc bug, it seems it has already been reported: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80717 and workaround different than this proposed here is available: https://bbs.archlinux.org/viewtopic.php?pid=1722955#p1722955 Haven't tested it. Workaround proposed here seems fine to me. Cordially, -- |
@NVieville we're already using avr-gcc-ar when we have avr-gcc > 4.9 (when LTO is enabled) i don't believe avr-ar will work with LTO at all, so can't be a workaround for this issue. thanks for testing my workaround. seems the archlinux guys have reverted a commit in avr-gcc 7.1.0-2 which the fedora guys haven't in 7.1.1-3 meaning that its still going to bite most users of avr-gcc >= 6.3 (luckily debian's still on 4.9.2 😏) as upstream haven't fixed it. @sudar / @ladislas any objections to merging my PR to workaround this? |
@sej7278 No objections for merging the PR. |
Hi All - Have a simple Arduino Uno project. Have a simple project that does use the following line and does generate the segmentation fault error as identified in this thread: However, I do not have a makefile system installed and do not have the brain cells nor time to figure out the 5 pages of instructions on the referenced github page for making it work. Wondering if there is a way to set/unset the necessary flags via environment variables inside the program rather than through makefile? Any simple fix without becoming Arduino compiler guru? Just have a few lines of code to run.... Thanks! |
Hmmm maybe found fix? Included SoftwareSerial.h and it appears to be compiling. |
I am using Arch Linux and everything seemed to work fine. However: When I try to use serial communication I get
lto1: internal compiler error: Segmentation fault
as soon as
Serial.begin(9600);
is uncommented. The same code works fine when compiling with the Arduino IDE.The makefile:
Arduino.mk Configuration:
Part of the code that leads to the error:
The text was updated successfully, but these errors were encountered: