Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7e2092a2 authored by Colin Cross's avatar Colin Cross
Browse files

Support BUILD_HOST_static=1 for musl and linux_bionic builds

BUILD_HOST_static=1 is useful for musl and linux_bionic builds to
produce standalone static binaries.

Bug: 179809553
Test: m USE_HOST_MUSL=true BUILD_HOST_static=1 apexer deapexer
Change-Id: Iac0f4ca92c3ffb27bccd4cac15a6ef9fa5924471
parent 4111c52f
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -220,19 +220,19 @@ func newBinary(hod android.HostOrDeviceSupported, bazelable bool) (*Module, *bin
func (binary *binaryDecorator) linkerInit(ctx BaseModuleContext) {
	binary.baseLinker.linkerInit(ctx)

	if !ctx.toolchain().Bionic() && !ctx.toolchain().Musl() {
		if ctx.Os() == android.Linux {
	if ctx.Os().Linux() && ctx.Host() {
		// Unless explicitly specified otherwise, host static binaries are built with -static
		// if HostStaticBinaries is true for the product configuration.
		if binary.Properties.Static_executable == nil && ctx.Config().HostStaticBinaries() {
			binary.Properties.Static_executable = BoolPtr(true)
		}
		} else {
	}

	if ctx.Darwin() || ctx.Windows() {
		// Static executables are not supported on Darwin or Windows
		binary.Properties.Static_executable = nil
	}
}
}

func (binary *binaryDecorator) static() bool {
	return Bool(binary.Properties.Static_executable)