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

Commit 8536d6b3 authored by Dan Willemsen's avatar Dan Willemsen
Browse files

Remove GCC checks

Clang is always used now, so we can remove all the GCC checks. Removing
GCC-specific configuration will happen in the next CL.

Test: m
Change-Id: I4835ecf6062159315d0dfb07b098e60bff033a8a
parent 230e4c77
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -302,8 +302,7 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
	if binary.stripper.needsStrip(ctx) {
		// b/80093681, GNU strip/objcopy bug.
		// Use llvm-{strip,objcopy} when clang lld is used.
		builderFlags.stripUseLlvmStrip =
			flags.Clang && binary.baseLinker.useClangLld(ctx)
		builderFlags.stripUseLlvmStrip = binary.baseLinker.useClangLld(ctx)
		strippedOutputFile := outputFile
		outputFile = android.PathForModuleOut(ctx, "unstripped", fileName)
		binary.stripper.strip(ctx, outputFile, strippedOutputFile, builderFlags)
+14 −45
Original line number Diff line number Diff line
@@ -242,7 +242,6 @@ type builderFlags struct {
	aidlFlags       string
	rsFlags         string
	toolchain       config.Toolchain
	clang           bool
	tidy            bool
	coverage        bool
	sAbiDump        bool
@@ -290,7 +289,7 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and

	objFiles := make(android.Paths, len(srcFiles))
	var tidyFiles android.Paths
	if flags.tidy && flags.clang {
	if flags.tidy {
		tidyFiles = make(android.Paths, 0, len(srcFiles))
	}
	var coverageFiles android.Paths
@@ -333,19 +332,14 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
	}, " ")

	var sAbiDumpFiles android.Paths
	if flags.sAbiDump && flags.clang {
	if flags.sAbiDump {
		sAbiDumpFiles = make(android.Paths, 0, len(srcFiles))
	}

	if flags.clang {
	cflags += " ${config.NoOverrideClangGlobalCflags}"
	toolingCflags += " ${config.NoOverrideClangGlobalCflags}"
	cppflags += " ${config.NoOverrideClangGlobalCflags}"
	toolingCppflags += " ${config.NoOverrideClangGlobalCflags}"
	} else {
		cflags += " ${config.NoOverrideGlobalCflags}"
		cppflags += " ${config.NoOverrideGlobalCflags}"
	}

	for i, srcFile := range srcFiles {
		objFile := android.ObjPathWithExt(ctx, subdir, srcFile, "o")
@@ -385,23 +379,23 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
		var moduleCflags string
		var moduleToolingCflags string
		var ccCmd string
		tidy := flags.tidy && flags.clang
		tidy := flags.tidy
		coverage := flags.coverage
		dump := flags.sAbiDump && flags.clang
		dump := flags.sAbiDump

		switch srcFile.Ext() {
		case ".S", ".s":
			ccCmd = "gcc"
			ccCmd = "clang"
			moduleCflags = asflags
			tidy = false
			coverage = false
			dump = false
		case ".c":
			ccCmd = "gcc"
			ccCmd = "clang"
			moduleCflags = cflags
			moduleToolingCflags = toolingCflags
		case ".cpp", ".cc", ".mm":
			ccCmd = "g++"
			ccCmd = "clang++"
			moduleCflags = cppflags
			moduleToolingCflags = toolingCppflags
		default:
@@ -409,24 +403,9 @@ func TransformSourceToObj(ctx android.ModuleContext, subdir string, srcFiles and
			continue
		}

		if flags.clang {
			switch ccCmd {
			case "gcc":
				ccCmd = "clang"
			case "g++":
				ccCmd = "clang++"
			default:
				panic("unrecoginzied ccCmd")
			}
		}

		ccDesc := ccCmd

		if flags.clang {
		ccCmd = "${config.ClangBin}/" + ccCmd
		} else {
			ccCmd = gccCmd(flags.toolchain, ccCmd)
		}

		var implicitOutputs android.WritablePaths
		if coverage {
@@ -611,12 +590,7 @@ func TransformObjToDynamicBinary(ctx android.ModuleContext,
	objFiles, sharedLibs, staticLibs, lateStaticLibs, wholeStaticLibs, deps android.Paths,
	crtBegin, crtEnd android.OptionalPath, groupLate bool, flags builderFlags, outputFile android.WritablePath) {

	var ldCmd string
	if flags.clang {
		ldCmd = "${config.ClangBin}/clang++"
	} else {
		ldCmd = gccCmd(flags.toolchain, "g++")
	}
	ldCmd := "${config.ClangBin}/clang++"

	var libFlagsList []string

@@ -777,12 +751,7 @@ func TransformSharedObjectToToc(ctx android.ModuleContext, inputFile android.Pat
func TransformObjsToObj(ctx android.ModuleContext, objFiles android.Paths,
	flags builderFlags, outputFile android.WritablePath) {

	var ldCmd string
	if flags.clang {
		ldCmd = "${config.ClangBin}/clang++"
	} else {
		ldCmd = gccCmd(flags.toolchain, "g++")
	}
	ldCmd := "${config.ClangBin}/clang++"

	ctx.Build(pctx, android.BuildParams{
		Rule:        partialLd,
+4 −18
Original line number Diff line number Diff line
@@ -136,7 +136,6 @@ type Flags struct {
	SystemIncludeFlags []string

	Toolchain config.Toolchain
	Clang     bool
	Tidy      bool
	Coverage  bool
	SAbiDump  bool
@@ -165,9 +164,6 @@ type BaseProperties struct {
	// Deprecated. true is the default, false is invalid.
	Clang *bool `android:"arch_variant"`

	// Some internals still need GCC (toolchain_library)
	Gcc bool `blueprint:"mutated"`

	// Minimum sdk version supported when compiling against the ndk
	Sdk_version *string

@@ -220,7 +216,6 @@ type VendorProperties struct {
type ModuleContextIntf interface {
	static() bool
	staticBinary() bool
	clang() bool
	toolchain() config.Toolchain
	useSdk() bool
	sdkVersion() string
@@ -513,10 +508,6 @@ type moduleContextImpl struct {
	ctx BaseModuleContext
}

func (ctx *moduleContextImpl) clang() bool {
	return ctx.mod.clang(ctx.ctx)
}

func (ctx *moduleContextImpl) toolchain() config.Toolchain {
	return ctx.mod.toolchain(ctx.ctx)
}
@@ -733,9 +724,12 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
		return
	}

	if c.Properties.Clang != nil && *c.Properties.Clang == false {
		ctx.PropertyErrorf("clang", "false (GCC) is no longer supported")
	}

	flags := Flags{
		Toolchain: c.toolchain(ctx),
		Clang:     c.clang(ctx),
	}
	if c.compiler != nil {
		flags = c.compiler.compilerFlags(ctx, flags, deps)
@@ -1099,14 +1093,6 @@ func BeginMutator(ctx android.BottomUpMutatorContext) {
	}
}

func (c *Module) clang(ctx BaseModuleContext) bool {
	if c.Properties.Clang != nil && *c.Properties.Clang == false {
		ctx.PropertyErrorf("clang", "false (GCC) is no longer supported")
	}

	return !c.Properties.Gcc
}

// Whether a module can link to another module, taking into
// account NDK linking.
func checkLinkType(ctx android.ModuleContext, from *Module, to *Module, tag dependencyTag) {
+4 −13
Original line number Diff line number Diff line
@@ -18,7 +18,6 @@ import (
	"fmt"

	"android/soong/android"
	"android/soong/cc/config"
	"os"
	"path"
	"path/filepath"
@@ -150,18 +149,10 @@ func generateCLionProject(compiledModule CompiledInterface, ctx android.Singleto
	f.WriteString(fmt.Sprintf("project(%s)\n", ccModule.ModuleBase.Name()))
	f.WriteString(fmt.Sprintf("set(ANDROID_ROOT %s)\n\n", getAndroidSrcRootDirectory(ctx)))

	if ccModule.flags.Clang {
	pathToCC, _ := evalVariable(ctx, "${config.ClangBin}/")
	f.WriteString(fmt.Sprintf("set(CMAKE_C_COMPILER \"%s%s\")\n", buildCMakePath(pathToCC), "clang"))
	f.WriteString(fmt.Sprintf("set(CMAKE_CXX_COMPILER \"%s%s\")\n", buildCMakePath(pathToCC), "clang++"))
	} else {
		toolchain := config.FindToolchain(ccModule.Os(), ccModule.Arch())
		root, _ := evalVariable(ctx, toolchain.GccRoot())
		triple, _ := evalVariable(ctx, toolchain.GccTriple())
		pathToCC := filepath.Join(root, "bin", triple+"-")
		f.WriteString(fmt.Sprintf("set(CMAKE_C_COMPILER \"%s%s\")\n", buildCMakePath(pathToCC), "gcc"))
		f.WriteString(fmt.Sprintf("set(CMAKE_CXX_COMPILER \"%s%s\")\n", buildCMakePath(pathToCC), "g++"))
	}

	// Add all sources to the project.
	f.WriteString("list(APPEND\n")
	f.WriteString("     SOURCE_FILES\n")
+24 −47
Original line number Diff line number Diff line
@@ -340,10 +340,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
	if flags.RequiredInstructionSet != "" {
		instructionSet = flags.RequiredInstructionSet
	}
	instructionSetFlags, err := tc.InstructionSetFlags(instructionSet)
	if flags.Clang {
		instructionSetFlags, err = tc.ClangInstructionSetFlags(instructionSet)
	}
	instructionSetFlags, err := tc.ClangInstructionSetFlags(instructionSet)
	if err != nil {
		ctx.ModuleErrorf("%s", err)
	}
@@ -353,7 +350,6 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
	// TODO: debug
	flags.CFlags = append(flags.CFlags, esc(compiler.Properties.Release.Cflags)...)

	if flags.Clang {
	CheckBadCompilerFlags(ctx, "clang_cflags", compiler.Properties.Clang_cflags)
	CheckBadCompilerFlags(ctx, "clang_asflags", compiler.Properties.Clang_asflags)

@@ -370,7 +366,6 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
	flags.CFlags = append(flags.CFlags, target, gccPrefix)
	flags.AsFlags = append(flags.AsFlags, target, gccPrefix)
	flags.LdFlags = append(flags.LdFlags, target, gccPrefix)
	}

	hod := "Host"
	if ctx.Os().Class == android.Device {
@@ -381,26 +376,16 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
	flags.ConlyFlags = append([]string{"${config.CommonGlobalConlyflags}"}, flags.ConlyFlags...)
	flags.CppFlags = append([]string{fmt.Sprintf("${config.%sGlobalCppflags}", hod)}, flags.CppFlags...)

	if flags.Clang {
	flags.AsFlags = append(flags.AsFlags, tc.ClangAsflags())
	flags.CppFlags = append([]string{"${config.CommonClangGlobalCppflags}"}, flags.CppFlags...)
	flags.GlobalFlags = append(flags.GlobalFlags,
		tc.ClangCflags(),
		"${config.CommonClangGlobalCflags}",
		fmt.Sprintf("${config.%sClangGlobalCflags}", hod))
	} else {
		flags.CppFlags = append([]string{"${config.CommonGlobalCppflags}"}, flags.CppFlags...)
		flags.GlobalFlags = append(flags.GlobalFlags,
			tc.Cflags(),
			"${config.CommonGlobalCflags}",
			fmt.Sprintf("${config.%sGlobalCflags}", hod))
	}

	if flags.Clang {
	if strings.HasPrefix(android.PathForModuleSrc(ctx).String(), "external/") {
		flags.GlobalFlags = append([]string{"${config.ClangExternalCflags}"}, flags.GlobalFlags...)
	}
	}

	if ctx.Device() {
		if Bool(compiler.Properties.Rtti) {
@@ -412,19 +397,11 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps

	flags.AsFlags = append(flags.AsFlags, "-D__ASSEMBLY__")

	if flags.Clang {
	flags.CppFlags = append(flags.CppFlags, tc.ClangCppflags())
	} else {
		flags.CppFlags = append(flags.CppFlags, tc.Cppflags())
	}

	flags.YasmFlags = append(flags.YasmFlags, tc.YasmFlags())

	if flags.Clang {
	flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainClangCflags())
	} else {
		flags.GlobalFlags = append(flags.GlobalFlags, tc.ToolchainCflags())
	}

	cStd := config.CStdVersion
	if String(compiler.Properties.C_std) == "experimental" {
Loading