Add LINKER_RELAXATIONS option to the LUFA BUILD build system module.
authorDean Camera <dean@fourwalledcubicle.com>
Sun, 30 Sep 2012 14:01:30 +0000 (14:01 +0000)
committerDean Camera <dean@fourwalledcubicle.com>
Sun, 30 Sep 2012 14:01:30 +0000 (14:01 +0000)
LUFA/Build/lufa_build.mk
LUFA/DoxygenPages/BuildSystem.txt
LUFA/DoxygenPages/LUFAPoweredProjects.txt

index 04596c5..ce76b60 100644 (file)
@@ -9,7 +9,7 @@
 LUFA_BUILD_MODULES         += BUILD
 LUFA_BUILD_TARGETS         += size symbol-sizes all lib elf hex lss clean mostlyclean
 LUFA_BUILD_MANDATORY_VARS  += TARGET ARCH MCU SRC F_USB LUFA_PATH
 LUFA_BUILD_MODULES         += BUILD
 LUFA_BUILD_TARGETS         += size symbol-sizes all lib elf hex lss clean mostlyclean
 LUFA_BUILD_MANDATORY_VARS  += TARGET ARCH MCU SRC F_USB LUFA_PATH
-LUFA_BUILD_OPTIONAL_VARS   += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE DEBUG_LEVEL
+LUFA_BUILD_OPTIONAL_VARS   += BOARD OPTIMIZATION C_STANDARD CPP_STANDARD F_CPU C_FLAGS CPP_FLAGS ASM_FLAGS CC_FLAGS LD_FLAGS OBJDIR OBJECT_FILES DEBUG_TYPE DEBUG_LEVEL LINKER_RELAXATIONS
 LUFA_BUILD_PROVIDED_VARS   += 
 LUFA_BUILD_PROVIDED_MACROS += 
 
 LUFA_BUILD_PROVIDED_VARS   += 
 LUFA_BUILD_PROVIDED_MACROS += 
 
@@ -60,6 +60,9 @@ LUFA_BUILD_PROVIDED_MACROS +=
 #    CC_FLAGS                  - Common flags to pass to the C/C++ compiler and
 #                                assembler
 #    LD_FLAGS                  - Flags to pass to the linker
 #    CC_FLAGS                  - Common flags to pass to the C/C++ compiler and
 #                                assembler
 #    LD_FLAGS                  - Flags to pass to the linker
+#    LINKER_RELAXATIONS        - Enable or disable linker relaxations to
+#                                decrease binary size (note: can cause link
+#                                failures on systems with an unpatched binutils)
 #    OBJDIR                    - Directory for the output object and dependency
 #                                files; if equal to ".", the output files will
 #                                be generated in the same folder as the sources
 #    OBJDIR                    - Directory for the output object and dependency
 #                                files; if equal to ".", the output files will
 #                                be generated in the same folder as the sources
@@ -86,19 +89,20 @@ ERROR_IF_EMPTY   ?= $(if $(strip $($(strip $(1)))), , $(error Makefile $(strip $
 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
 
 # Default values of optionally user-supplied variables
 ERROR_IF_NONBOOL ?= $(if $(filter Y N, $($(strip $(1)))), , $(error Makefile $(strip $(1)) option must be Y or N))
 
 # Default values of optionally user-supplied variables
-BOARD           ?= NONE
-OPTIMIZATION    ?= s
-F_CPU           ?=
-C_STANDARD      ?= gnu99
-CPP_STANDARD    ?= gnu++98
-C_FLAGS         ?=
-CPP_FLAGS       ?=
-ASM_FLAGS       ?=
-CC_FLAGS        ?=
-OBJDIR          ?= .
-OBJECT_FILES    ?=
-DEBUG_FORMAT    ?= dwarf-2
-DEBUG_LEVEL     ?= 2
+BOARD              ?= NONE
+OPTIMIZATION       ?= s
+F_CPU              ?=
+C_STANDARD         ?= gnu99
+CPP_STANDARD       ?= gnu++98
+C_FLAGS            ?=
+CPP_FLAGS          ?=
+ASM_FLAGS          ?=
+CC_FLAGS           ?=
+OBJDIR             ?= .
+OBJECT_FILES       ?=
+DEBUG_FORMAT       ?= dwarf-2
+DEBUG_LEVEL        ?= 2
+LINKER_RELAXATIONS ?= Y
 
 # Sanity check user supplied values
 $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
 
 # Sanity check user supplied values
 $(foreach MANDATORY_VAR, $(LUFA_BUILD_MANDATORY_VARS), $(call ERROR_IF_UNSET, $(MANDATORY_VAR)))
@@ -114,6 +118,7 @@ $(call ERROR_IF_EMPTY, CPP_STANDARD)
 $(call ERROR_IF_EMPTY, OBJDIR)
 $(call ERROR_IF_EMPTY, DEBUG_FORMAT)
 $(call ERROR_IF_EMPTY, DEBUG_LEVEL)
 $(call ERROR_IF_EMPTY, OBJDIR)
 $(call ERROR_IF_EMPTY, DEBUG_FORMAT)
 $(call ERROR_IF_EMPTY, DEBUG_LEVEL)
+$(call ERROR_IF_NONBOOL, LINKER_RELAXATIONS)
 
 # Determine the utility prefix to use for the selected architecture
 ifeq ($(ARCH), AVR8)
 
 # Determine the utility prefix to use for the selected architecture
 ifeq ($(ARCH), AVR8)
@@ -194,7 +199,10 @@ BASE_CPP_FLAGS := -x c++ -O$(OPTIMIZATION) -std=$(CPP_STANDARD)
 BASE_ASM_FLAGS := -x assembler-with-cpp
 
 # Create a list of flags to pass to the linker
 BASE_ASM_FLAGS := -x assembler-with-cpp
 
 # Create a list of flags to pass to the linker
-BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections -Wl,--relax 
+BASE_LD_FLAGS := -lm -Wl,-Map=$(TARGET).map,--cref -Wl,--gc-sections
+ifeq ($(LINKER_RELAXATIONS), Y)
+   BASE_LD_FLAGS += -Wl,--relax
+endif
 ifeq ($(ARCH), AVR8)
    BASE_LD_FLAGS += -mmcu=$(MCU)
 else ifeq ($(ARCH), XMEGA)
 ifeq ($(ARCH), AVR8)
    BASE_LD_FLAGS += -mmcu=$(MCU)
 else ifeq ($(ARCH), XMEGA)
index 57a01d9..3ee524b 100644 (file)
  *    <td>Flags to pass to the linker, after the automatically generated flags.</td>\r
  *   </tr>\r
  *   <tr>\r
  *    <td>Flags to pass to the linker, after the automatically generated flags.</td>\r
  *   </tr>\r
  *   <tr>\r
+ *    <td><tt>LINKER_RELAXATIONS</tt></td>\r
+ *    <td>Enables or disables linker relaxations when linking the application binary. This can reduce the total size\r
+ *        of the application by replacing full \c CALL instructions with smaller \c RCALL instructions where possible.\r
+ *        \note On some unpatched versions of binutils, this can cause link failures in some circumstances. If you\r
+ *              receive a link error <tt>relocation truncated to fit: R_AVR_13_PCREL</tt>, disable this setting.</td>\r
+ *   </tr>\r
+ *   <tr>\r
  *    <td><tt>OBJDIR</tt></td>\r
  *    <td>Directory to place the generated object and dependency files. If set to "." the same folder as the source file will be used.\r
  *        \note When this option is enabled, all source filenames <b>must</b> be unique.</td>\r
  *    <td><tt>OBJDIR</tt></td>\r
  *    <td>Directory to place the generated object and dependency files. If set to "." the same folder as the source file will be used.\r
  *        \note When this option is enabled, all source filenames <b>must</b> be unique.</td>\r
index f456432..99a0f26 100644 (file)
  *  \li CFFA3000, a CompactFlash interface for the Apple II: http://www.dreher.net/CFforAppleII
  *  \li Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/
  *  \li FinchRobot, a robot designed for educational use: http://www.finchrobot.com/
  *  \li CFFA3000, a CompactFlash interface for the Apple II: http://www.dreher.net/CFforAppleII
  *  \li Digital Survey Instruments Magnetometer and Pointer: http://www.digitalsurveyinstruments.com/
  *  \li FinchRobot, a robot designed for educational use: http://www.finchrobot.com/
+ *  \li Flysight, a GPS logger for wingsuit pilots: http://flysight.ca/
  *  \li HummingBird Kit, a robotics learning platform: http://www.hummingbirdkit.com/
  *  \li Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR
  *  \li PIR-1, an IR control interface for consumer electronics: http://www.promixis.com/pir-1.php
  *  \li HummingBird Kit, a robotics learning platform: http://www.hummingbirdkit.com/
  *  \li Penguino, an Arduino Board With On-Board LUFA Powered Debugger/Programmer: http://wiki.icy.com.au/PenguinoAVR
  *  \li PIR-1, an IR control interface for consumer electronics: http://www.promixis.com/pir-1.php
  *  \li Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org
  *  \li RFI21.1EU UHF RFID reader: http://www.metra.cz/rfid/uhf-rfid-ctecky/rfi21-1eu-uhf-rfid-ctecka.htm
  *  \li SmartCardDetective, a Smart Card analysis tool: http://www.smartcarddetective.com/
  *  \li Retrode, a USB Games Console Cartridge Reader: http://www.retrode.org
  *  \li RFI21.1EU UHF RFID reader: http://www.metra.cz/rfid/uhf-rfid-ctecky/rfi21-1eu-uhf-rfid-ctecka.htm
  *  \li SmartCardDetective, a Smart Card analysis tool: http://www.smartcarddetective.com/
+ *  \li TimelapsePlus, a digital camera time lapse tool: https://github.com/timelapseplus/TimelapsePlus-Firmware
  *  \li USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php
  *  \li UDS18B20 USB Temperature sensor: http://toughlog.org/uds18b20/
  *  \li VMeter, a USB MIDI touch strip controller: http://www.vmeter.net/
  *  \li USBTINY-MKII, an AVRISP-MKII Clone AVR Programmer: http://tom-itx.dyndns.org:81/~webpage/boards/USBTiny_Mkii/USBTiny_Mkii_index.php
  *  \li UDS18B20 USB Temperature sensor: http://toughlog.org/uds18b20/
  *  \li VMeter, a USB MIDI touch strip controller: http://www.vmeter.net/