Skip to content

Commit 12beda0

Browse files
authored
Merge pull request #141 from vilhelmgray/strip
Implement the '-strip' & '-nostrip' compiler options. Add the ENABLE_STRIPALL build option for default.
2 parents 0a04c42 + aa55af4 commit 12beda0

File tree

3 files changed

+31
-1
lines changed

3 files changed

+31
-1
lines changed

changelog.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ Version 1.07.0
55
[added]
66
- CVA_LIST type, CVA_START(), CVA_COPY() CVA_END(), CVA_ARG() macros will map to gcc's __builtin_va_list and __builtin_va_* macros in gcc backend
77
- github #133: fbc makefile supports bootstrap-minimal target to build a bootstrap fbc with only the minimal features necessary to build another fbc. (William Breathitt Gray)
8+
- github #141: introduced '-strip'/'-nostrip' options to control symbol stripping of output files (William Breathitt Gray)
9+
- github #141: fbc will default to stripping symbols if '-d ENABLE_STRIPALL' is passed in FBCFLAGS (William Breathitt Gray)
10+
- github #141: makefile option 'ENABLE_STRIPALL=1' introduced to pass '-d ENABLE_STRIPALL' via FBCFLAGS by default for dos/win32 targets (William Breathitt Gray)
811

912
[fixed]
1013
- sf.net #881: C backend: support for varadic function parameters in gcc using __builtin_va_list type and related macros

makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
# ENABLE_SUFFIX=-0.24 append a string like "-0.24" to fbc/FB dir names,
8282
# and use "-d ENABLE_SUFFIX=$(ENABLE_SUFFIX)" (non-standalone only)
8383
# ENABLE_LIB64=1 use prefix/lib64/ instead of prefix/lib/ for 64bit libs (non-standalone only)
84+
# ENABLE_STRIPALL=1 use "-d ENABLE_STRIPALL" with select targets
8485
# FBPACKAGE bindist: The package/archive file name without path or extension
8586
# FBPACKSUFFIX bindist: Allows adding a custom suffix to the normal package name (and the toplevel dir in the archive)
8687
# FBMANIFEST bindist: The manifest file name without path or extension
@@ -92,6 +93,7 @@
9293
# -d ENABLE_SUFFIX=-0.24 assume FB's lib dir uses the given suffix (non-standalone only)
9394
# -d ENABLE_PREFIX=/some/path hard-code specific $(prefix) into fbc
9495
# -d ENABLE_LIB64 use prefix/lib64/ instead of prefix/lib/ for 64bit libs (non-standalone only)
96+
# -d ENABLE_STRIPALL configure fbc to pass down '--strip-all' to linker by default
9597
#
9698
# rtlib/gfxlib2 source code configuration (CFLAGS):
9799
# -DDISABLE_X11 build without X11 headers (disables X11 gfx driver)
@@ -429,6 +431,12 @@ endif
429431
ifdef ENABLE_LIB64
430432
ALLFBCFLAGS += -d ENABLE_LIB64
431433
endif
434+
ifdef ENABLE_STRIPALL
435+
ifneq ($(filter dos win32,$(TARGET_OS)),)
436+
ALLFBCFLAGS += -d ENABLE_STRIPALL
437+
endif
438+
endif
439+
432440

433441
ALLFBCFLAGS += $(FBCFLAGS) $(FBFLAGS)
434442
ALLFBLFLAGS += $(FBLFLAGS) $(FBFLAGS)

src/compiler/fbc.bas

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ type FBCCTX
100100
xbe_title as zstring * FB_MAXNAMELEN+1 '' For the '-title <title>' xbox option
101101
nodeflibs as integer
102102
staticlink as integer
103+
stripsymbols as integer
103104

104105
'' Compiler paths
105106
prefix as zstring * FB_MAXPATHLEN+1 '' Path from -prefix or empty
@@ -163,6 +164,10 @@ private sub fbcInit( )
163164

164165
fbGlobalInit()
165166

167+
#ifdef ENABLE_STRIPALL
168+
fbc.stripsymbols = TRUE
169+
#endif
170+
166171
fbc.objinf.lang = fbGetOption( FB_COMPOPT_LANG )
167172

168173
fbc.print = -1
@@ -762,7 +767,7 @@ private function hLinkFiles( ) as integer
762767

763768
if( fbGetOption( FB_COMPOPT_DEBUGINFO ) = FALSE ) then
764769
if( fbGetOption( FB_COMPOPT_PROFILE ) = FALSE ) then
765-
if( fbGetOption( FB_COMPOPT_TARGET ) <> FB_COMPTARGET_DARWIN ) then
770+
if( fbc.stripsymbols ) then
766771
ldcline += " -s"
767772
end if
768773
end if
@@ -1417,6 +1422,7 @@ enum
14171422
OPT_NODEFLIBS
14181423
OPT_NOERRLINE
14191424
OPT_NOOBJINFO
1425+
OPT_NOSTRIP
14201426
OPT_O
14211427
OPT_OPTIMIZE
14221428
OPT_P
@@ -1432,6 +1438,7 @@ enum
14321438
OPT_S
14331439
OPT_SHOWINCLUDES
14341440
OPT_STATIC
1441+
OPT_STRIP
14351442
OPT_T
14361443
OPT_TARGET
14371444
OPT_TITLE
@@ -1480,6 +1487,7 @@ dim shared as integer option_takes_argument(0 to (OPT__COUNT - 1)) = _
14801487
FALSE, _ '' OPT_NODEFLIBS
14811488
FALSE, _ '' OPT_NOERRLINE
14821489
FALSE, _ '' OPT_NOOBJINFO
1490+
FALSE, _ '' OPT_NOSTRIP
14831491
TRUE , _ '' OPT_O
14841492
TRUE , _ '' OPT_OPTIMIZE
14851493
TRUE , _ '' OPT_P
@@ -1495,6 +1503,7 @@ dim shared as integer option_takes_argument(0 to (OPT__COUNT - 1)) = _
14951503
TRUE , _ '' OPT_S
14961504
FALSE, _ '' OPT_SHOWINCLUDES
14971505
FALSE, _ '' OPT_STATIC
1506+
FALSE, _ '' OPT_STRIP
14981507
TRUE , _ '' OPT_T
14991508
TRUE , _ '' OPT_TARGET
15001509
TRUE , _ '' OPT_TITLE
@@ -1676,6 +1685,9 @@ private sub handleOpt(byval optid as integer, byref arg as string)
16761685
case OPT_NOOBJINFO
16771686
fbSetOption( FB_COMPOPT_OBJINFO, FALSE )
16781687

1688+
case OPT_NOSTRIP
1689+
fbc.stripsymbols = FALSE
1690+
16791691
case OPT_O
16801692
'' Error if there already is an -o waiting to be assigned
16811693
hCheckWaitingObjfile( )
@@ -1765,6 +1777,9 @@ private sub handleOpt(byval optid as integer, byref arg as string)
17651777
case OPT_STATIC
17661778
fbc.staticlink = TRUE
17671779

1780+
case OPT_STRIP
1781+
fbc.stripsymbols = TRUE
1782+
17681783
case OPT_T
17691784
fbSetOption( FB_COMPOPT_STACKSIZE, clng( arg ) * 1024 )
17701785

@@ -1963,6 +1978,7 @@ private function parseOption(byval opt as zstring ptr) as integer
19631978
CHECK("noerrline", OPT_NOERRLINE)
19641979
CHECK("nodeflibs", OPT_NODEFLIBS)
19651980
CHECK("noobjinfo", OPT_NOOBJINFO)
1981+
CHECK("nostrip", OPT_NOSTRIP)
19661982

19671983
case asc("o")
19681984
ONECHAR(OPT_O)
@@ -1990,6 +2006,7 @@ private function parseOption(byval opt as zstring ptr) as integer
19902006
ONECHAR(OPT_S)
19912007
CHECK("showincludes", OPT_SHOWINCLUDES)
19922008
CHECK("static", OPT_STATIC)
2009+
CHECK("strip", OPT_STRIP)
19932010

19942011
case asc("t")
19952012
ONECHAR(OPT_T)
@@ -3384,6 +3401,7 @@ private sub hPrintOptions( )
33843401
print " -nodeflibs Do not include the default libraries"
33853402
print " -noerrline Do not show source context in error messages"
33863403
print " -noobjinfo Do not read/write compile-time info from/to .o and .a files"
3404+
print " -nostrip Do not strip symbol information from the output file"
33873405
print " -o <file> Set .o (or -pp .bas) file name for prev/next input file"
33883406
print " -O <value> Optimization level (default: 0)"
33893407
print " -p <path> Add a library search path"
@@ -3401,6 +3419,7 @@ private sub hPrintOptions( )
34013419
print " -s console|gui Select win32 subsystem"
34023420
print " -showincludes Display a tree of file names of #included files"
34033421
print " -static Prefer static libraries over dynamic ones when linking"
3422+
print " -strip Omit all symbol information from the output file"
34043423
print " -t <value> Set .exe stack size in kbytes, default: 1024 (win32/dos)"
34053424
print " -target <name> Set cross-compilation target"
34063425
print " -title <name> Set XBE display title (xbox)"

0 commit comments

Comments
 (0)