File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -515,6 +515,32 @@ impl Step for Llvm {
515515 }
516516 }
517517
518+ // When building LLVM as a shared library on linux, it can contain unexpected debuginfo:
519+ // some can come from the C++ standard library. Unless we're explicitly requesting LLVM to
520+ // be built with debuginfo, strip it away after the fact, to make dist artifacts smaller.
521+ // FIXME: to make things simpler for now, limit this to the host and target where we know
522+ // `strip -g` is both available and will fix the issue, i.e. on a x64 linux host that is not
523+ // cross-compiling. Expand this to other appropriate targets in the future.
524+ if builder. llvm_link_shared ( )
525+ && builder. config . llvm_optimize
526+ && !builder. config . llvm_release_debuginfo
527+ && target == "x86_64-unknown-linux-gnu"
528+ && target == builder. config . build
529+ {
530+ // Find the name of the LLVM shared library that we just built.
531+ let lib_name = find_llvm_lib_name ( "so" ) ;
532+
533+ // If the shared library exists in LLVM's `/build/lib/` or `/lib/` folders, strip its
534+ // debuginfo. Note: `output` will propagate any errors here.
535+ let strip_if_possible = |path : PathBuf | {
536+ if path. exists ( ) {
537+ output ( Command :: new ( "strip" ) . arg ( "--strip-debug" ) . arg ( path) ) ;
538+ }
539+ } ;
540+ strip_if_possible ( out_dir. join ( "lib" ) . join ( & lib_name) ) ;
541+ strip_if_possible ( out_dir. join ( "build" ) . join ( "lib" ) . join ( & lib_name) ) ;
542+ }
543+
518544 t ! ( stamp. write( ) ) ;
519545
520546 res
You can’t perform that action at this time.
0 commit comments