Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: Remove -extldflags "-static" from LDFLAGS
Using this flag is actually misleading, as it's ineffective unless '-linkmode external' is used. With the current LDFLAGS, whether we get a static build or not is highly dependent on the arch, on the code being compiled, on the use of cgo or not, ... but there are no guarantees at all that the build will be static. $ go build -ldflags '-s -w -extldflags "-static"' -o routes-controller . $ ldd routes-controller linux-vdso.so.1 (0x00007ffd2dcc4000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fb2a4888000) libc.so.6 => /lib64/libc.so.6 (0x00007fb2a46b9000) /lib64/ld-linux-x86-64.so.2 (0x00007fb2a48bf000) $ CGO_ENABLED=0 go build -ldflags '-s -w -extldflags "-static"' -o routes-controller . $ ldd routes-controller not a dynamic executable $ CGO_ENABLED=0 go build -ldflags '-s -w' -o routes-controller . $ ldd routes-controller not a dynamic executable On my machine, the `crc` binary generated by `make cross` dynamically links to libc regardless of the presence or not of this flag. Moreover, static linking would require installation of glibc-static on some arches, but statically linking against glibc is not supported on some OSes (RHEL8). This commit removes the `-extldflags "-static"` LDFLAGS from Makefile. The binaries are unchanged before/after that change (same size, and very few content differences)
- Loading branch information