Linker occasionally misinterprets command line

Bug #1807865 reported by Martin Hierholzer
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
gcc-avr (Ubuntu)
New
Undecided
Unassigned

Bug Description

After I updated from Ubuntu 18.04 to 18.10, avr-g++ sometimes fails to link a project (which is built automatically on Jenkins). It seems to misinterpret the command line by taking one of the define options ("-Dsomething"), stripping the "-D" and then using the remaining token as a file name. This leads to an error message like "avr-g++: error: something: No such file or directory" (in case of "-Dsomething"). I ran the command (just the link command manually at the command line) multiple times without any change, and the error occurs with something like 50% probability.

The real full command line is this:

jenkins@tartaros:~/workspace/Repetier_RFx000_community_development/PRINTER/RF1000/build$ /usr/bin/avr-g++ -Os -w --std=c++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -DMOTHERBOARD=DEVICE_TYPE_RF1000 -Os -w --std=c++11 -fno-exceptions -ffunction-sections -fdata-sections -fno-threadsafe-statics -MMD -w -Os -Wl,--gc-sections -fuse-linker-plugin -Wl,--gc-sections,--relax -w -Os -Wl,--gc-sections -fuse-linker-plugin -Wl,--gc-sections,--relax -mmcu=atmega2560 -flto CMakeFiles/Repetier.dir/Repetier_Repetier.ino.cpp.obj CMakeFiles/Repetier.dir/Commands.cpp.obj CMakeFiles/Repetier.dir/Communication.cpp.obj CMakeFiles/Repetier.dir/Eeprom.cpp.obj CMakeFiles/Repetier.dir/Extruder.cpp.obj CMakeFiles/Repetier.dir/HAL.cpp.obj CMakeFiles/Repetier.dir/Printer.cpp.obj CMakeFiles/Repetier.dir/RF.cpp.obj CMakeFiles/Repetier.dir/SDCard.cpp.obj CMakeFiles/Repetier.dir/gcode.cpp.obj CMakeFiles/Repetier.dir/motion.cpp.obj CMakeFiles/Repetier.dir/ui.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/MinimumSerial.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/FatFile.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/FatFileLFN.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/FatFilePrint.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/FatFileSFN.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/FatVolume.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/FmtNumber.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/StdioStream.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/fstream.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/istream.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/FatLib/ostream.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/SdCard/SdSpiCard.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/SdCard/SdSpiCardEX.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/SdCard/SdioCardEX.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/SdCard/SdioTeensy.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/SpiDriver/SdSpiESP8266.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/SpiDriver/SdSpiSAM3X.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/SpiDriver/SdSpiSTM32.cpp.obj CMakeFiles/Repetier.dir/src/SdFat/SpiDriver/SdSpiTeensy3.cpp.obj -o Repetier.elf libmega_SPI.a libmega_Wire.a libmega_twi.a libmega_CORE.a -lc -lm

The exact output on failure is this:

avr-g++: error: MOTHERBOARD=DEVICE_TYPE_RF1000: No such file or directory
lto-wrapper: fatal error: /usr/bin/avr-g++ returned 1 exit status
compilation terminated.
/usr/lib/gcc/avr/5.4.0/../../../avr/bin/ld: error: lto-wrapper failed
collect2: error: ld returned 1 exit status

In case of no failure, no output is printed and the elf file is successfully produced. The behaviour seems to depend on the order of command line options. I cannot reproduce the error if I put the define option in question ("-DMOTHERBOARD=DEVICE_TYPE_RF1000") at the end of the command line instead. (This may be a work around, but it might be difficult to change the order of arguments in my case since this is a cmake project.)

Additional information:

1) lsb_release -rd
Description: Ubuntu 18.10
Release: 18.10

2) apt-cache policy gcc-avr
gcc-avr:
  Installed: 1:5.4.0+Atmel3.6.1-1
  Candidate: 1:5.4.0+Atmel3.6.1-1
  Version table:
 *** 1:5.4.0+Atmel3.6.1-1 500
        500 http://de.archive.ubuntu.com/ubuntu cosmic/universe amd64 Packages
        100 /var/lib/dpkg/status

3) Expected behaviour: Always produce the elf file without an error message.

4) Instead I got random failures with the error message mentioned above.

description: updated
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.