Skip to content

Commit 514c975

Browse files
authored
[BE] Strip symbols from the C++ extension in release builds (#3859)
1 parent ed22b88 commit 514c975

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

setup.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,12 @@ def get_extensions():
267267
"-DWITH_CUDA",
268268
]
269269
extra_link_args = ["-O0", "-g"]
270+
else:
271+
# setuptools appends Python's sysconfig CFLAGS (which include -g)
272+
# to the compile command, leaving ~20 MB of debug info in the
273+
# extension. Strip symbols at link time in release builds; the
274+
# dynamic symbol table (needed by dlopen) is unaffected.
275+
extra_link_args = ["-Wl,-x"] if sys.platform == "darwin" else ["-Wl,-s"]
270276

271277
extensions_dir = "torchrl/csrc"
272278

0 commit comments

Comments
 (0)