Skip to content

Commit

Permalink
Enable LTO during device release builds, remove duplicated symbols
Browse files Browse the repository at this point in the history
  • Loading branch information
samdze committed Dec 3, 2023
1 parent 7542a8d commit a57932d
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
43 changes: 23 additions & 20 deletions src/playdate/api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,34 @@ macro initSDK*() =
handler(event, arg)
return 0

when not defined(simulator):
proc fini() {.cdecl, exportc: "_fini".} =
discard
# when not defined(simulator):
# proc fini() {.cdecl, exportc: "_fini".} =
# discard

when not defined(simulator) and defined(release):
proc close(file: cint): cint {.cdecl, exportc: "_close".} =
return -1
# when not defined(simulator) and defined(release):
# proc realloc_r(reent: pointer, aptr: pointer, bytes: csize_t): pointer {.cdecl, exportc: "_realloc_r".} =
# return nil

proc fstat(file: cint, st: pointer): cint {.cdecl, exportc: "_fstat".} =
return -1
# proc close(file: cint): cint {.cdecl, exportc: "_close".} =
# return -1

proc getpid(): cint {.cdecl, exportc: "_getpid".} =
return 1
# proc fstat(file: cint, st: pointer): cint {.cdecl, exportc: "_fstat".} =
# return -1

proc isatty(file: cint): cint {.cdecl, exportc: "_isatty".} =
return 0
# proc getpid(): cint {.cdecl, exportc: "_getpid".} =
# return 1

proc kill(pid, sig: cint): cint {.cdecl, exportc: "_kill".} =
return 0
# proc isatty(file: cint): cint {.cdecl, exportc: "_isatty".} =
# return 0

proc lseek(file, pos, whence: cint): cint {.cdecl, exportc: "_lseek".} =
return -1
# proc kill(pid, sig: cint): cint {.cdecl, exportc: "_kill".} =
# return 0

proc read(file: cint, pt: ptr cchar, len: cint): cint {.cdecl, exportc: "_read".} =
return 0
# proc lseek(file, pos, whence: cint): cint {.cdecl, exportc: "_lseek".} =
# return -1

proc write(handle: cint, data: ptr cchar, size: cint): cint {.cdecl, exportc: "_write".} =
return -1
# proc read(file: cint, pt: ptr cchar, len: cint): cint {.cdecl, exportc: "_read".} =
# return 0

# proc write(handle: cint, data: ptr cchar, size: cint): cint {.cdecl, exportc: "_write".} =
# return -1
13 changes: 9 additions & 4 deletions src/playdate/build/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@ when defined(device):
switch("passC", "-DTARGET_PLAYDATE=1")
switch("passC", "-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__FPU_USED=1")
switch("passC", "-falign-functions=16 -fomit-frame-pointer -gdwarf-2 -fverbose-asm")
switch("passC", "-ffunction-sections -fdata-sections -mword-relocations -fno-common")
switch("passC", "-ffunction-sections -fdata-sections -mword-relocations -fno-common -flto")
# Disabled warnings
switch("passC", "-Wno-unused-but-set-variable -Wno-unused-label -Wno-parentheses -Wno-discarded-qualifiers -Wno-array-bounds")

switch("passL", "-nostartfiles")
switch("passL", "-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__FPU_USED=1")
switch("passL", "-mthumb -mcpu=cortex-m7 -mfloat-abi=hard -mfpu=fpv5-sp-d16 -D__FPU_USED=1 -flto")
switch("passL", "-T" & sdkPath() / "C_API" / "buildsupport" / "link_map.ld")
switch("passL", "-Wl,-Map=game.map,--cref,--gc-sections,--emit-relocs")
switch("passL", "--entry eventHandlerShim")
Expand All @@ -73,8 +73,13 @@ when defined(device):
switch("index", "off")
switch("stackTrace", "off")
switch("lineTrace", "off")
switch("passC", "--specs=nosys.specs")
switch("passL", "-lnosys --specs=nosys.specs")
# switch("passC", "--specs=nosys.specs")
# switch("passL", "--specs=nosys.specs -lnosys")
switch("passC", "--specs=nano.specs")
switch("passL", "--specs=nano.specs -lnosys")
# switch("passL", "--specs=nano.specs -lc_nano")
# switch("passL", "--specs=nosys.specs -lnosys")
# switch("passL", "-lrdimon --specs=rdimon.specs")
else:
switch("define", "debug")
switch("opt", "none")
Expand Down

0 comments on commit a57932d

Please sign in to comment.