Page MenuHomeFreeBSD

Build toolchain components as dynamically linked executables by default
ClosedPublic

Authored by dim on Oct 16 2019, 8:34 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 16, 2:12 AM
Unknown Object (File)
Thu, Apr 11, 6:48 PM
Unknown Object (File)
Thu, Apr 11, 6:48 PM
Unknown Object (File)
Thu, Apr 11, 6:48 PM
Unknown Object (File)
Tue, Apr 9, 8:49 PM
Unknown Object (File)
Thu, Apr 4, 3:41 PM
Unknown Object (File)
Jan 15 2024, 12:02 PM
Unknown Object (File)
Dec 23 2023, 4:18 PM

Details

Summary

Historically, we have built toolchain components such as cc, ld, etc as
statically linked executables. One of the reasons being that you could
sometimes save yourself from botched upgrades, by e.g. recompiling a
"known good" libc and reinstalling it.

In this day and age, we have boot environments, virtual machine
snapshots, cloud backups, and other much more reliable methods to
restore systems to working order. So I think the time is ripe to flip
this default, and link the toolchain components dynamically, just like
almost all other executables on FreeBSD.

Maybe at some point they can even become PIE executables by default! :)

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 27076
Build 25358: arc lint + arc unit

Event Timeline

This revision is now accepted and ready to land.Oct 16 2019, 9:04 PM

Maybe at some point they can even become PIE executables by default! :)

What's holding this up btw? Is there any actual reason why we have any non-PIE executables at all on aarch64 and amd64?

In D22061#482304, @greg_unrelenting.technology wrote:

Maybe at some point they can even become PIE executables by default! :)

What's holding this up btw? Is there any actual reason why we have any non-PIE executables at all on aarch64 and amd64?

The MK_PIE knob was added in a "default NO" state in rS344179 by @emaste on 2019-02-15, so it has been in there for a while. Probably nobody ran extensive tests yet with it enabled? The commit itself also has a few remarks on why certain executables do not yet have PIE enabled. I also remember there were some people posting issues with PIE and ASLR on the mailing lists, which may have been solved by now.

Historically, another reason was performance. For example, https://svnweb.freebsd.org/base?view=revision&revision=76801 which changed make(1) to be statically linked states performance as the reason.

Since the performance gain of static linking is in exec, exit, fork and calls across library boundaries, I imagine the gain is limited for a compiler or linker that uses considerable CPU time by itself but for things like make installworld a static make might be significantly faster.