Skip to content

Commit 7ce23fd

Browse files
committed
make: Remove linker stuff from OS makefile, clarify difference between stripped and minimal
1 parent b5376b2 commit 7ce23fd

2 files changed

Lines changed: 13 additions & 41 deletions

File tree

src/Makefile

Lines changed: 6 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ INC_NEWLIB=$(INSTALL)/newlib/include
4040
CC = $(shell command -v clang-3.8 || command -v clang-3.6)
4141
CPP = $(shell command -v clang++-3.8 || command -v clang++-3.6 || command -v clang++)
4242
# Set defaults if not defined
43-
ifndef LD_INC
44-
LD_INC = ld
45-
endif
4643
ifndef AR_INC
4744
AR_INC = ar
4845
endif
@@ -59,7 +56,6 @@ CINCLUDES = -I../api/sys -I$(INC_NEWLIB) -Iinclude -I../api
5956

6057
CCOPTS += $(CAPABS) $(WARNS) -c -m32 -march=i686 $(CINCLUDES)
6158
CPPOPTS += $(CAPABS) $(WARNS) -c -m32 -std=c++14 $(INCLUDES) -D_LIBCPP_HAS_NO_THREADS=1 -DOS_VERSION="\"$(shell git describe --dirty)\""
62-
LDOPTS = -nostdlib -melf_i386 -N --eh-frame-hdr --script=linker.ld
6359

6460
# Objects
6561
###################################################
@@ -106,7 +102,7 @@ CRTN_OBJ = crt/crtn.o
106102
###################################################
107103
OS_DEPS = $(OS_OBJECTS:.o=.d)
108104

109-
.PHONY: memdisk all debug stripped minimal clean
105+
.PHONY: all stripped minimal debug silent clean
110106

111107
# Complete OS build
112108
###################################################
@@ -118,10 +114,12 @@ all: CAPABS += -O2
118114
all: includeos
119115
@echo "\n>>> Built OS-library. Install to '"$(INSTALL)"' using 'make install'"
120116

121-
stripped: CAPABS += -Os
122-
stripped: LDOPTS += -s
117+
stripped: CAPABS += -O2
123118
stripped: includeos
124119

120+
minimal: CAPABS += -Os
121+
minimal: includeos
122+
125123
# Build like "all" but with debugging output (i.e. the 'debug'-macro) enabled
126124
debug-info: CAPABS += -UNO_DEBUG
127125
debug-info: CAPABS += -DGSL_THROW_ON_CONTRACT_VIOLATION
@@ -144,31 +142,8 @@ debug-all: includeos test
144142
silent: CPPOPTS += -DNO_INFO=1
145143
silent: includeos
146144

147-
minimal: CPPOPTS += -ffunction-sections -fdata-sections
148-
minimal: LDOPTS += --gc-sections
149-
minimal: stripped
150-
151145
includeos: bootloader multiboot libc++abi.a os.a drivers platforms
152146

153-
# Test service
154-
###################################################
155-
LIBS_OBJ = os.a $(LIBCXX) os.a $(LIBC_OBJ) $(LIBM_OBJ) $(LIBGCC)
156-
157-
158-
CRTBEGIN_OBJ = $(CRTI_OBJ) $(INSTALL)/crt/crtbegin.o
159-
CRTEND_OBJ = $(INSTALL)/crt/crtend.o $(CRTN_OBJ)
160-
161-
TEST_OBJ = debug/test_service.o util/service_name.o
162-
163-
test_service: CPPOPTS += -DSERVICE_NAME="\"Test Service\""
164-
test_service: $(TEST_OBJ) $(CRTI_OBJ) $(CRTN_OBJ)
165-
@echo "\n>> Linking test service"
166-
@echo "\n>> LDOPTS = $(LDOPTS)"
167-
touch smalldisk
168-
$(LD_INC) -v $(LDOPTS) $(CRTBEGIN_OBJ) $(TEST_OBJ) $(LIBS_OBJ) $(CRTEND_OBJ) -o debug/$@
169-
170-
test: test_service
171-
172147
# OS libraries
173148
###################################################
174149
# OS
@@ -252,10 +227,7 @@ etags:
252227

253228
# Cleanup
254229
###################################################
255-
clean_tests:
256-
$(RM) debug/*.o debug/*.d debug/*.img debug/test_service debug/test_ipv6 debug/test_tcp
257-
258-
clean: clean_tests
230+
clean:
259231
$(RM) $(OS_OBJECTS) $(CXXABI_OBJ) $(OS_DEPS) $(DRIVERS) $(DRIVERS_DEPS) $(PLATFORMS) $(PLATFORMS_DEPS)
260232
$(RM) os.a libc++abi.a
261233
$(RM) bootloader apic_boot apic_boot.o boot/multiboot.o

src/seed/Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ INSTALL = $(INCLUDEOS_INSTALL)
2222

2323
# Compiler and linker options
2424
###################################################
25-
CAPABS_COMMON = -mstackrealign -msse3 -fstack-protector-strong
25+
CAPABS_COMMON = -mstackrealign -msse3 -fstack-protector-strong -DOS_TERMINATE_ON_CONTRACT_VIOLATION
2626
WARNS = -Wall -Wextra #-pedantic
2727
DEBUG_OPTS = -ggdb3 -v
2828

@@ -52,9 +52,10 @@ endif
5252

5353
INCLUDES = -I$(INC_LIBCXX) -I$(INSTALL)/api/sys -I$(INC_NEWLIB) -I$(INSTALL)/api -I$(INSTALL)/mod/GSL $(LOCAL_INCLUDES)
5454

55-
all: CAPABS = $(CAPABS_COMMON) -O2 -DOS_TERMINATE_ON_CONTRACT_VIOLATION
55+
all: CAPABS = $(CAPABS_COMMON) -O2
5656
debug: CAPABS = $(CAPABS_COMMON) -O0
57-
stripped: CAPABS = $(CAPABS_COMMON) -Os
57+
stripped: CAPABS = $(CAPABS_COMMON) -O2
58+
5859
# by default, don't use strip because it has caused us some problems
5960
STRIPPED=--strip-debug
6061

@@ -110,7 +111,7 @@ debug-info: service
110111
debug: CCOPTS += $(DEBUG_OPTS)
111112
debug: CPPOPTS += $(DEBUG_OPTS)
112113
debug: OBJ_LIST += $(LIBG_OBJ)
113-
debug: CAPABS += -O0
114+
debug: CPPOPTS += -O0
114115
debug: STRIPPED=
115116
debug: service
116117

@@ -119,12 +120,11 @@ debug-all: CAPABS += -UNO_DEBUG
119120
debug-all: CCOPTS += $(DEBUG_OPTS)
120121
debug-all: CPPOPTS += $(DEBUG_OPTS)
121122
debug-all: OBJ_LIST += $(LIBG_OBJ)
122-
debug-all: CAPABS += -O0
123+
debug-all: CPPOPTS += -O0
123124
debug-all: service
124125

125-
minimal: CPPOPTS += -ffunction-sections -fdata-sections
126-
minimal: LDOPTS += --gc-sections
127126
minimal: stripped
127+
minimal: CPPOPTS += -Os
128128

129129
# Service
130130
###################################################

0 commit comments

Comments
 (0)