Skip to content

Commit

Permalink
Merge pull request #327 from lanodan/objcopy-strip-envvar
Browse files Browse the repository at this point in the history
Use $OBJCOPY and $STRIP instead of hardcoding
  • Loading branch information
thepowersgang committed Jan 15, 2024
2 parents 967eea0 + c5f66b1 commit 666bda1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
9 changes: 6 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ V ?= !
# GPROF : If set, enables the generation of a gprof annotated executable
GPROF ?=

OBJCOPY ?= objcopy
STRIP ?= strip

ifneq ($(VERBOSE),)
V :=
endif
Expand Down Expand Up @@ -169,9 +172,9 @@ else ifeq ($(shell uname -s || echo not),Darwin)
$V$(CXX) -o $@ $(LINKFLAGS) $(OBJDIR)main.o -Wl,-all_load bin/mrustc.a bin/common_lib.a $(LIBS)
else
$V$(CXX) -o $@ $(LINKFLAGS) $(OBJDIR)main.o -Wl,--whole-archive bin/mrustc.a -Wl,--no-whole-archive bin/common_lib.a $(LIBS)
objcopy --only-keep-debug $(BIN) $(BIN).debug
objcopy --add-gnu-debuglink=$(BIN).debug $(BIN)
strip $(BIN)
$(OBJCOPY) --only-keep-debug $(BIN) $(BIN).debug
$(OBJCOPY) --add-gnu-debuglink=$(BIN).debug $(BIN)
$(STRIP) $(BIN)
endif

$(OBJDIR)%.o: src/%.cpp
Expand Down
9 changes: 6 additions & 3 deletions tools/minicargo/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ ifeq ($(OS),Windows_NT)
endif
EXESUF ?=

OBJCOPY ?= objcopy
STRIP ?= strip

V ?= @

OBJDIR := .obj/
Expand Down Expand Up @@ -41,9 +44,9 @@ $(BIN): $(OBJS) ../../bin/common_lib.a
ifeq ($(OS),Windows_NT)
else ifeq ($(shell uname -s || echo not),Darwin)
else
objcopy --only-keep-debug $(BIN) $(BIN).debug
objcopy --add-gnu-debuglink=$(BIN).debug $(BIN)
strip $(BIN)
$(OBJCOPY) --only-keep-debug $(BIN) $(BIN).debug
$(OBJCOPY) --add-gnu-debuglink=$(BIN).debug $(BIN)
$(STRIP) $(BIN)
endif

$(OBJDIR)%.o: %.cpp
Expand Down

0 comments on commit 666bda1

Please sign in to comment.