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

Commit 7061f792 authored by Colin Cross's avatar Colin Cross Committed by Gerrit Code Review
Browse files

Merge changes I7fdc1f53,I422315f0,Ia34b80d9

* changes:
  Move default crt objects into Toolchain
  Add DefaultSharedLibraries to Toolchain
  Create toolchainBionic for the various bionic-based toolchains to inherit from
parents 63496676 d1a28130
Loading
Loading
Loading
Loading
+9 −16
Original line number Diff line number Diff line
@@ -146,16 +146,17 @@ func (binary *binaryDecorator) getStem(ctx BaseModuleContext) string {
// modules common to most binaries, such as bionic libraries.
func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
	deps = binary.baseLinker.linkerDeps(ctx, deps)
	if ctx.toolchain().Bionic() {
	if !Bool(binary.baseLinker.Properties.Nocrt) {
		if binary.static() {
				deps.CrtBegin = []string{"crtbegin_static"}
			deps.CrtBegin = ctx.toolchain().CrtBeginStaticBinary()
			deps.CrtEnd = ctx.toolchain().CrtEndStaticBinary()
		} else {
				deps.CrtBegin = []string{"crtbegin_dynamic"}
			deps.CrtBegin = ctx.toolchain().CrtBeginSharedBinary()
			deps.CrtEnd = ctx.toolchain().CrtEndSharedBinary()
		}
			deps.CrtEnd = []string{"crtend_android"}
	}

	if ctx.toolchain().Bionic() {
		if binary.static() {
			if ctx.selectedStl() == "libc++_static" {
				deps.StaticLibs = append(deps.StaticLibs, "libm", "libc")
@@ -169,16 +170,8 @@ func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
			deps.LateStaticLibs = append(groupLibs, deps.LateStaticLibs...)
		}

		// Embed the linker into host bionic binaries. This is needed to support host bionic,
		// as the linux kernel requires that the ELF interpreter referenced by PT_INTERP be
		// either an absolute path, or relative from CWD. To work around this, we extract
		// the load sections from the runtime linker ELF binary and embed them into each host
		// bionic binary, omitting the PT_INTERP declaration. The kernel will treat it as a static
		// binary, and then we use a special entry point to fix up the arguments passed by
		// the kernel before jumping to the embedded linker.
		if ctx.Os() == android.LinuxBionic && !binary.static() {
			deps.DynamicLinker = "linker"
			deps.CrtBegin = append(deps.CrtBegin, "host_bionic_linker_script")
		}
	}

+2 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@ bootstrap_go_package {
        "toolchain.go",
        "vndk.go",

        "bionic.go",

        "arm_device.go",
        "arm64_device.go",
        "arm64_fuchsia_device.go",
+1 −0
Original line number Diff line number Diff line
@@ -149,6 +149,7 @@ var (
)

type toolchainArm64 struct {
	toolchainBionic
	toolchain64Bit

	ldflags              string
+0 −4
Original line number Diff line number Diff line
@@ -82,10 +82,6 @@ func (t *toolchainFuchsiaArm64) ClangCflags() string {
	return "--target=arm64-fuchsia --sysroot=" + fuchsiaArm64SysRoot + " -I" + fuchsiaArm64SysRoot + "/include"
}

func (t *toolchainFuchsiaArm64) Bionic() bool {
	return false
}

func (t *toolchainFuchsiaArm64) ToolchainClangCflags() string {
	return "-march=armv8-a"
}
+14 −0
Original line number Diff line number Diff line
@@ -45,6 +45,16 @@ var (
		"-Wl,--hash-style=gnu",
		"-Wl,--no-undefined-version",
	})

	// Embed the linker into host bionic binaries. This is needed to support host bionic,
	// as the linux kernel requires that the ELF interpreter referenced by PT_INTERP be
	// either an absolute path, or relative from CWD. To work around this, we extract
	// the load sections from the runtime linker ELF binary and embed them into each host
	// bionic binary, omitting the PT_INTERP declaration. The kernel will treat it as a static
	// binary, and then we use a special entry point to fix up the arguments passed by
	// the kernel before jumping to the embedded linker.
	linuxArm64CrtBeginSharedBinary = append(android.CopyOf(bionicCrtBeginSharedBinary),
		"host_bionic_linker_script")
)

func init() {
@@ -68,6 +78,10 @@ func (toolchainLinuxArm64) ClangCflags() string {
	return "${config.Arm64ClangCflags} ${config.LinuxBionicArm64Cflags}"
}

func (toolchainLinuxArm64) CrtBeginSharedBinary() []string {
	return linuxArm64CrtBeginSharedBinary
}

func linuxArm64ToolchainFactory(arch android.Arch) Toolchain {
	archVariant := "armv8-a" // for host, default to armv8-a
	toolchainClangCflags := []string{arm64ClangArchVariantCflagsVar[archVariant]}
Loading