Skip to content

Commit 56f4f00

Browse files
committed
add garbage collection to avoid unused dependencies
1 parent 072bcf1 commit 56f4f00

File tree

4 files changed

+34
-2
lines changed

4 files changed

+34
-2
lines changed

benchmark/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,15 @@ CSTD ?= -std=c90
4747

4848
ASFLAGS ?= $(ARCHFLAGS)
4949
CFLAGS ?= $(ARCHFLAGS) $(CSTD) $(CFLAGS_EXTRA)
50-
LDFLAGS ?= $(ARCHFLAGS)
50+
LDFLAGS ?= $(ARCHFLAGS)
51+
52+
# Enable garbage collection. Inexact handling of dead_strip
53+
OS_NAME := $(shell uname -s | tr A-Z a-z)
54+
ifeq ($(OS_NAME),darwin)
55+
LDFLAGS += -Wl,-dead_strip
56+
else
57+
LDFLAGS += -Wl,--gc-sections
58+
endif
5159

5260
# LD: generate map
5361
#LDFLAGS += -Wl,-map,$(BUILD_DIR)/$(BIN).map

examples/posix/tcp/wh_client_tcp/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,14 @@ ASFLAGS ?= $(ARCHFLAGS)
4949
CFLAGS ?= $(ARCHFLAGS) $(CSTD) $(CFLAGS_EXTRA)
5050
LDFLAGS ?= $(ARCHFLAGS)
5151

52+
# Enable garbage collection. Inexact handling of dead_strip
53+
OS_NAME := $(shell uname -s | tr A-Z a-z)
54+
ifeq ($(OS_NAME),darwin)
55+
LDFLAGS += -Wl,-dead_strip
56+
else
57+
LDFLAGS += -Wl,--gc-sections
58+
endif
59+
5260
# LD: generate map
5361
#LDFLAGS += -Wl,-map,$(BUILD_DIR)/$(BIN).map
5462
#LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(BIN).map

examples/posix/tcp/wh_server_tcp/Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,14 @@ CFLAGS_EXTRA ?= -Wextra
4040
CFLAGS ?= $(ARCHFLAGS) -Wno-cpp -std=c99 -Wall -Werror $(CFLAGS_EXTRA)
4141
LDFLAGS ?= $(ARCHFLAGS)
4242

43+
# Enable garbage collection. Inexact handling of dead_strip
44+
OS_NAME := $(shell uname -s | tr A-Z a-z)
45+
ifeq ($(OS_NAME),darwin)
46+
LDFLAGS += -Wl,-dead_strip
47+
else
48+
LDFLAGS += -Wl,--gc-sections
49+
endif
50+
4351
# LD: generate map
4452
#LDFLAGS += -Wl,-map,$(BUILD_DIR)/$(BIN).map
4553
#LDFLAGS += -Wl,-Map=$(BUILD_DIR)/$(BIN).map

test/Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,15 @@ CSTD ?= -std=c90
4545

4646
ASFLAGS ?= $(ARCHFLAGS)
4747
CFLAGS ?= $(ARCHFLAGS) $(CSTD) $(CFLAGS_EXTRA)
48-
LDFLAGS ?= $(ARCHFLAGS)
48+
LDFLAGS ?= $(ARCHFLAGS)
49+
50+
# Enable garbage collection. Inexact handling of dead_strip
51+
OS_NAME := $(shell uname -s | tr A-Z a-z)
52+
ifeq ($(OS_NAME),darwin)
53+
LDFLAGS += -Wl,-dead_strip
54+
else
55+
LDFLAGS += -Wl,--gc-sections
56+
endif
4957

5058
# LD: generate map
5159
#LDFLAGS += -Wl,-map,$(BUILD_DIR)/$(BIN).map

0 commit comments

Comments
 (0)