Skip to content

Commit

Permalink
squash introduce ILINK, ILINKFLAGS
Browse files Browse the repository at this point in the history
  • Loading branch information
Joakim Nohlgård committed Mar 1, 2018
1 parent 9ef9132 commit 2e0d00d
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 2 deletions.
11 changes: 9 additions & 2 deletions Makefile.base
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,15 @@ $(BINDIR)/$(MODULE)/:

$(BINDIR)/$(MODULE).o $(OBJ): | $(BINDIR)/$(MODULE)/

$(BINDIR)/$(MODULE).o: $(OBJ) | ${DIRS:%=ALL--%}
$(Q)[ -z '$^' ] || $(LD) -r -o $@ $^
# An empty object file is included in the link to avoid situations where modules
# do not provide any code (e.g. sys, some boards), causing the build to fail
# with a missing object file.
EMPTYOBJ = $(BINDIR)/$(MODULE)/.empty.o
$(EMPTYOBJ): | $(BINDIR)/$(MODULE)/
$(Q)$(CC) $(CFLAGS) -Wno-pedantic -xc -o $@ -c - < /dev/null

$(BINDIR)/$(MODULE).o: $(OBJ) $(EMPTYOBJ) | ${DIRS:%=ALL--%}
$(Q)$(ILINK) $(ILINKFLAGS) -o $@ $^

CXXFLAGS = $(filter-out $(CXXUWFLAGS), $(CFLAGS)) $(CXXEXFLAGS)
CCASFLAGS = $(filter-out $(CCASUWFLAGS), $(CFLAGS)) $(CCASEXFLAGS)
Expand Down
1 change: 1 addition & 0 deletions boards/native/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export CXXEXFLAGS +=

ifeq ($(shell uname -m),x86_64)
export LINKFLAGS += -m32
export ILINKFLAGS += -r -m elf_i386
endif
ifeq ($(shell uname -s),FreeBSD)
ifeq ($(shell uname -m),amd64)
Expand Down
3 changes: 3 additions & 0 deletions cpu/atmega1281/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# tell the build system that the CPU depends on the atmega common files
USEMODULE += atmega_common

# CPU family, see https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
export CPU_FAM = avr51

# define path to atmega common module, which is needed for this CPU
export ATMEGA_COMMON = $(RIOTCPU)/atmega_common/

Expand Down
3 changes: 3 additions & 0 deletions cpu/atmega2560/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# tell the build system that the CPU depends on the atmega common files
USEMODULE += atmega_common

# CPU family, see https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
export CPU_FAM = avr6

# define path to atmega common module, which is needed for this CPU
export ATMEGA_COMMON = $(RIOTCPU)/atmega_common/

Expand Down
3 changes: 3 additions & 0 deletions cpu/atmega328p/Makefile.include
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
# tell the build system that the CPU depends on the atmega common files
USEMODULE += atmega_common

# CPU family, see https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html
export CPU_FAM = avr5

# define path to atmega common module, which is needed for this CPU
export ATMEGA_COMMON = $(RIOTCPU)/atmega_common/

Expand Down
3 changes: 3 additions & 0 deletions cpu/atmega_common/Makefile.include
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ export CFLAGS_OPT ?= -Os

export CFLAGS += $(CFLAGS_CPU) $(CFLAGS_LINK) $(CFLAGS_DBG) $(CFLAGS_OPT)
export ASFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG)
# See https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html for information on
# which CPU_FAM corresponds to your CPU
export ILINKFLAGS += -r -m $(CPU_FAM)
export LINKFLAGS += $(CFLAGS_CPU) $(CFLAGS_DBG) $(CFLAGS_OPT) -static -lgcc -e reset_handler -Wl,--gc-sections

# export the peripheral drivers to be linked into the final binary
Expand Down
2 changes: 2 additions & 0 deletions makefiles/toolchain/gnu.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export AR = $(PREFIX)ar
endif
export AS = $(PREFIX)as
export LD = $(PREFIX)ld
export ILINK = $(LD)
export ILINKFLAGS ?= -r
export LINK = $(PREFIX)gcc
export LINKXX = $(PREFIX)g++
export SIZE = $(PREFIX)size
Expand Down
2 changes: 2 additions & 0 deletions makefiles/toolchain/llvm.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export NM = $(LLVMPREFIX)nm
# `makefiles/libc/newlib.mk` are not supported. Therefore
# we just use GCC for now.
export LD = $(PREFIX)ld
export ILINK = $(LD)
export ILINKFLAGS ?= -r
export LINK = $(PREFIX)gcc
export LINKXX = $(PREFIX)g++
# objcopy does not have a clear substitute in LLVM, use GNU binutils
Expand Down
2 changes: 2 additions & 0 deletions makefiles/vars.inc.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export AR # The command to create the object file archives.
export ARFLAGS # Command-line options to pass to AR, default `rcs`.
export AS # The assembler.
export ASFLAGS # Flags for the assembler.
export ILINK # Command used to perform incremental linking to create intermediate object files. Usually "ld"
export ILINKFLAGS # Incremental link command line options.
export LINK # The command used to link the files. Must take the same parameters as GCC, i.e. "ld" won't work.
export LINKFLAGS # Flags to supply in the linking step.
export LTOFLAGS # extra CFLAGS for compiling with link time optimization
Expand Down

0 comments on commit 2e0d00d

Please sign in to comment.