You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This request aims to reduce the size of the Go binary (rpc-go.exe) and the associated DLL/SO files. By decreasing the file sizes, we can improve the user experience, especially for users working with corporate laptops that may have limited disk space and have plenty of IT installed applications.
Go Build with -ldflags "-w -s"
Compile with -ldflags="-w -s": Implementing this flag combination will strip debug and symbol table information from the binaries without affecting the functionality of rpc-go.exe. This will significantly reduce the size of the binaries while maintaining full functionality.
ldflags
The go build command allows the use of linker flags to modify the way the final binary is created. Two particularly useful flags for reducing binary size are:
-w: This flag omits the DWARF symbol table, effectively removing debugging information.
-s: This strips the symbol table and debug information from the binary.
More information:
The -w turns off DWARF debugging information: you will not be able to use gdb on the binary to look at specific functions or set breakpoints or get stack traces, because all the metadata gdb needs will not be included. You will also not be able to use other tools that depend on the information, like pprof profiling.
The -s turns off generation of the Go symbol table: you will not be able to use go tool nm to list the symbols in the binary. strip -s is like passing -s to -ldflags but it doesn't strip quite as much. go tool nm might still work after strip -s. I am not completely sure.
I will make a note to include these optional build flags in our documentation to give folks the choice if they manually opt to build the executable or library rather than use the tagged release artifacts. I'll tag this issue when updated.
Problem Statement
This request aims to reduce the size of the Go binary (rpc-go.exe) and the associated DLL/SO files. By decreasing the file sizes, we can improve the user experience, especially for users working with corporate laptops that may have limited disk space and have plenty of IT installed applications.
Go Build with -ldflags "-w -s"
Compile with -ldflags="-w -s": Implementing this flag combination will strip debug and symbol table information from the binaries without affecting the functionality of rpc-go.exe. This will significantly reduce the size of the binaries while maintaining full functionality.
ldflags
The go build command allows the use of linker flags to modify the way the final binary is created. Two particularly useful flags for reducing binary size are:
-w: This flag omits the DWARF symbol table, effectively removing debugging information.
-s: This strips the symbol table and debug information from the binary.
More information:
The -w turns off DWARF debugging information: you will not be able to use gdb on the binary to look at specific functions or set breakpoints or get stack traces, because all the metadata gdb needs will not be included. You will also not be able to use other tools that depend on the information, like pprof profiling.
The -s turns off generation of the Go symbol table: you will not be able to use go tool nm to list the symbols in the binary. strip -s is like passing -s to -ldflags but it doesn't strip quite as much. go tool nm might still work after strip -s. I am not completely sure.
Before reduction
After reduction
Reference:
The text was updated successfully, but these errors were encountered: