Commit 84df8890 authored by Alessandro Rubini's avatar Alessandro Rubini

build: avoid libraries: arch and protocols include OBJ-y instead

This simplifies the build system, by relying in weak symbols instead
of the link order. We need weak symbols anyways for configuration, so
we can get rid of the libraries.  The size of binaries returned at
build time is increased, because arch/ and lib/ stuff is not part of
ppsi.o (as it actually should).
Signed-off-by: Alessandro Rubini's avatarAlessandro Rubini <rubini@gnudd.com>
parent c2dd5980
...@@ -91,8 +91,8 @@ export CFLAGS ...@@ -91,8 +91,8 @@ export CFLAGS
# libraries: see proto-standard/Makefile as an example. # libraries: see proto-standard/Makefile as an example.
$(TARGET).o: silentoldconfig $(OBJ-y) $(TARGET).o: silentoldconfig $(OBJ-y)
$(LD) -Map $(TARGET).map1 -r -o $@ $(OBJ-y) $(PPSI_O_LDFLAGS) \ $(LD) -Map $(TARGET).map1 -r -o $@ $(PPSI_O_LDFLAGS) \
--start-group $(LIBS) --end-group --start-group $(OBJ-y) --end-group
# Finally, "make clean" is expected to work # Finally, "make clean" is expected to work
clean: clean:
......
CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds ARCH_LDFLAGS = -nostdlib -static -T $A/$(ARCH).lds
# We need to undefine _FORTIFY_SOURCE, to prevent picking up external # We need to undefine _FORTIFY_SOURCE, to prevent picking up external
# symbols in the inline versions of strcpy etc. This is documented in # symbols in the inline versions of strcpy etc. This is documented in
...@@ -13,9 +13,8 @@ L := lib-bare ...@@ -13,9 +13,8 @@ L := lib-bare
CFLAGS += -Ilib-bare CFLAGS += -Ilib-bare
LIBARCH := $A/libarch.a OBJ-y += $A/crt0.o \
$L/bare-startup.o \
OBJ-libarch := $L/bare-startup.o \
$L/main-loop.o \ $L/main-loop.o \
$L/bare-io.o \ $L/bare-io.o \
$A/syscalls.o \ $A/syscalls.o \
...@@ -28,14 +27,10 @@ OBJ-libarch := $L/bare-startup.o \ ...@@ -28,14 +27,10 @@ OBJ-libarch := $L/bare-startup.o \
TIME := bare TIME := bare
include time-bare/Makefile include time-bare/Makefile
$(LIBARCH): $(OBJ-libarch)
$(AR) r $@ $^
all: $(TARGET) all: $(TARGET)
# to build the target, we need -lstd again, in case we call functions that # to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_open_globals() ). # were not selected yet (e.g., pp_open_globals() ).
$(TARGET): $(TARGET).o $A/crt0.o $(LIBARCH) $(TARGET): $(TARGET).o
$(CC) -Wl,-Map,$(TARGET).map2 $(ARCH_LDFLAGS) -o $@ $A/crt0.o \ $(CC) -Wl,-Map,$(TARGET).map2 $(ARCH_LDFLAGS) -o $@ $(TARGET).o
$(TARGET).o -L$A -larch -L$D -lstd
CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools CFLAGS += -ffreestanding -Os -fno-stack-protector -Itools
ARCH_LDFLAGS = -nostdlib -static -T $(ARCH).lds ARCH_LDFLAGS = -nostdlib -static -T $A/$(ARCH).lds
# We need to undefine _FORTIFY_SOURCE, to prevent picking up external # We need to undefine _FORTIFY_SOURCE, to prevent picking up external
# symbols in the inline versions of strcpy etc. This is documented in # symbols in the inline versions of strcpy etc. This is documented in
...@@ -13,9 +13,8 @@ L := lib-bare ...@@ -13,9 +13,8 @@ L := lib-bare
CFLAGS += -Ilib-bare CFLAGS += -Ilib-bare
LIBARCH := $A/libarch.a OBJ-y += $A/crt0.o \
$L/bare-startup.o \
OBJ-libarch := $L/bare-startup.o \
$L/main-loop.o \ $L/main-loop.o \
$L/bare-io.o \ $L/bare-io.o \
$A/syscall.o \ $A/syscall.o \
...@@ -36,7 +35,6 @@ all: $(TARGET) ...@@ -36,7 +35,6 @@ all: $(TARGET)
# to build the target, we need -lstd again, in case we call functions that # to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_open_globals() ). # were not selected yet (e.g., pp_open_globals() ).
$(TARGET): $(TARGET).o $A/crt0.o $(LIBARCH) $(TARGET): $(TARGET).o
$(CC) -Wl,-Map,$(TARGET).map2 $(ARCH_LDFLAGS) -o $@ $A/crt0.o \ $(CC) -Wl,-Map,$(TARGET).map2 $(ARCH_LDFLAGS) -o $@ $(TARGET).o
$(TARGET).o -L$A -larch -L$D -lstd
...@@ -4,10 +4,7 @@ A := arch-$(ARCH) ...@@ -4,10 +4,7 @@ A := arch-$(ARCH)
CFLAGS += -Itools CFLAGS += -Itools
OBJ-y += $A/unix-startup.o \
LIBARCH := $A/libarch.a
OBJ-libarch := $A/unix-startup.o \
$A/main-loop.o \ $A/main-loop.o \
$A/unix-io.o \ $A/unix-io.o \
lib/cmdline.o \ lib/cmdline.o \
...@@ -22,17 +19,15 @@ TIME ?= unix ...@@ -22,17 +19,15 @@ TIME ?= unix
include time-$(TIME)/Makefile include time-$(TIME)/Makefile
# Unix time operations are always included as a fallback # Unix time operations are always included as a fallback
ifneq ($(TIME),unix)
include time-unix/Makefile include time-unix/Makefile
endif
CFLAGS += -Itime-unix CFLAGS += -Itime-unix
$(LIBARCH): $(OBJ-libarch)
$(AR) r $@ $^
all: $(TARGET) all: $(TARGET)
# to build the target, we need -lstd again, in case we call functions that # to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_open_globals() ). # were not selected yet (e.g., pp_open_globals() ).
$(TARGET): $(TARGET).o $(LIBARCH) $(TARGET): $(TARGET).o
$(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o \ $(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o -lrt
-L$A -larch -L$D -lstd -lrt
...@@ -17,12 +17,7 @@ CONFIG_NO_PRINTF = y ...@@ -17,12 +17,7 @@ CONFIG_NO_PRINTF = y
# All files are under A (short for ARCH): I'm lazy # All files are under A (short for ARCH): I'm lazy
A := arch-$(ARCH) A := arch-$(ARCH)
LIBARCH := $A/libarch.a OBJ-y += \
LIBS += -L$A -larch
OBJ-libarch := \
$A/wrpc-io.o \ $A/wrpc-io.o \
$A/wrpc-spll.o \ $A/wrpc-spll.o \
$A/wrpc-calibration.o \ $A/wrpc-calibration.o \
...@@ -34,7 +29,4 @@ OBJ-libarch := \ ...@@ -34,7 +29,4 @@ OBJ-libarch := \
TIME := wrpc TIME := wrpc
include time-wrpc/Makefile include time-wrpc/Makefile
$(LIBARCH): $(OBJ-libarch)
$(AR) r $@ $^
$(TARGET).o: $(LIBARCH) $(TARGET).o: $(LIBARCH)
...@@ -3,10 +3,7 @@ A := arch-$(ARCH) ...@@ -3,10 +3,7 @@ A := arch-$(ARCH)
CFLAGS += -Itools CFLAGS += -Itools
OBJ-y += $A/wrs-startup.o \
LIBARCH := $A/libarch.a
OBJ-libarch := $A/wrs-startup.o \
$A/main-loop.o \ $A/main-loop.o \
$A/wrs-io.o \ $A/wrs-io.o \
$A/wrs-calibration.o \ $A/wrs-calibration.o \
...@@ -36,14 +33,12 @@ CFLAGS += -I$(MINIPC_DIR) ...@@ -36,14 +33,12 @@ CFLAGS += -I$(MINIPC_DIR)
$(MINIPC_LIB): $(MINIPC_LIB):
$(MAKE) -C $(MINIPC_DIR) $(MAKE) -C $(MINIPC_DIR)
$(LIBARCH): $(OBJ-libarch) $(MINIPC_LIB) OBJ-y += $(MINIPC_LIB)
$(AR) r $@ $^
all: $(TARGET) all: $(TARGET)
# to build the target, we need -lstd again, in case we call functions that # to build the target, we need -lstd again, in case we call functions that
# were not selected yet (e.g., pp_open_globals() ). # were not selected yet (e.g., pp_open_globals() ).
$(TARGET): $(TARGET).o $(LIBARCH) $(TARGET): $(TARGET).o
$(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o \ $(CC) -Wl,-Map,$(TARGET).map2 -o $@ $(TARGET).o -lrt
-L$A -larch -L$D -L$(MINIPC_DIR) -lminipc -lstd -lrt
...@@ -2,11 +2,7 @@ ...@@ -2,11 +2,7 @@
# All files are under directory D: I'm lazy # All files are under directory D: I'm lazy
D := proto-ext-whiterabbit D := proto-ext-whiterabbit
# don't link as a library, but as a big object. Otherwise we loose open/close OBJ-y += $D/fsm-table.o \
LIBWRO := $D/libwr.o
LIBS += $(LIBWRO)
OBJ-libwr := $D/fsm-table.o \
$D/hooks.o \ $D/hooks.o \
$D/state-wr-present.o \ $D/state-wr-present.o \
$D/state-wr-m-lock.o \ $D/state-wr-m-lock.o \
...@@ -18,8 +14,3 @@ OBJ-libwr := $D/fsm-table.o \ ...@@ -18,8 +14,3 @@ OBJ-libwr := $D/fsm-table.o \
$D/state-wr-link-on.o \ $D/state-wr-link-on.o \
$D/wr-msg.o \ $D/wr-msg.o \
$D/wr-servo.o $D/wr-servo.o
$(TARGET).o: $(LIBWRO)
$(LIBWRO): $(OBJ-libwr)
$(LD) -r $^ -o $@
...@@ -3,11 +3,7 @@ ...@@ -3,11 +3,7 @@
# All files are under D: I'm lazy # All files are under D: I'm lazy
D := proto-standard D := proto-standard
LIBSTD := $D/libstd.a OBJ-y += $D/fsm-table.o \
LIBS += -L$D -lstd
OBJ-libstd := $D/fsm-table.o \
$D/state-initializing.o \ $D/state-initializing.o \
$D/state-faulty.o \ $D/state-faulty.o \
$D/state-disabled.o \ $D/state-disabled.o \
...@@ -25,8 +21,3 @@ OBJ-libstd := $D/fsm-table.o \ ...@@ -25,8 +21,3 @@ OBJ-libstd := $D/fsm-table.o \
$D/hooks.o \ $D/hooks.o \
$D/timeout.o \ $D/timeout.o \
$D/open-close.o $D/open-close.o
$(TARGET).o: $(LIBSTD)
$(LIBSTD): $(OBJ-libstd)
$(AR) r $@ $^
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
* the linker can avoid pulling this data space if another table is there. * the linker can avoid pulling this data space if another table is there.
*/ */
struct pp_state_table_item pp_state_table[] = { struct pp_state_table_item pp_state_table[] __attribute__((weak)) = {
{ PPS_INITIALIZING, "initializing", pp_initializing,}, { PPS_INITIALIZING, "initializing", pp_initializing,},
{ PPS_FAULTY, "faulty", pp_faulty,}, { PPS_FAULTY, "faulty", pp_faulty,},
{ PPS_DISABLED, "disabled", pp_disabled,}, { PPS_DISABLED, "disabled", pp_disabled,},
......
#include <ppsi/ppsi.h> #include <ppsi/ppsi.h>
/* proto-standard offers all-null hooks as a default extension */ /* proto-standard offers all-null hooks as a default extension */
struct pp_ext_hooks pp_hooks; struct pp_ext_hooks __attribute__((weak)) pp_hooks;
# This Makefile in included by architectures that select time-bare # This Makefile in included by architectures that select time-bare
# Object files are added to libarch, so they are picked on demand. # Object files are added straight, as they are always needed
OBJ-libarch += \ OBJ-y += \
time-bare/bare-time.o \ time-bare/bare-time.o \
time-bare/bare-socket.o time-bare/bare-socket.o
# This Makefile in included by architectures that select time-unix # This Makefile in included by architectures that select time-unix
# as a default, or by builds with explicit TIME=unix. # as a default, or by builds with explicit TIME=unix.
# Object files are added to libarch, so they are picked on demand. # Object files are added straight, as they are always needed
OBJ-libarch += \ OBJ-y += \
time-unix/unix-time.o \ time-unix/unix-time.o \
time-unix/unix-socket.o time-unix/unix-socket.o
OBJ-libarch += \ OBJ-y += \
time-wrs/wrs-time.o \ time-wrs/wrs-time.o \
time-wrs/wrs-socket.o time-wrs/wrs-socket.o
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment