aboutsummaryrefslogtreecommitdiff
path: root/compiler_wrapper/config.go
diff options
context:
space:
mode:
authorTobias Bosch <tbosch@google.com>2019-08-19 09:55:30 -0700
committerTobias Bosch <tbosch@google.com>2019-08-19 20:57:09 +0000
commitd8aa0d03924683c67577b6e0725f3f8a90dce0bc (patch)
treebdff67d1fddfa8d7e4382c745507627b780af022 /compiler_wrapper/config.go
parent1c95e747af51c784a7bdbf9a584f67e90bab32df (diff)
downloadtoolchain-utils-d8aa0d03924683c67577b6e0725f3f8a90dce0bc.tar.gz
Store change id as version in the config.
This helps in debugging the wrapper. The version can be printed via the -print-config command. BUG=chromium:773875 TEST=unit test Change-Id: Ic6f84b4ccaa4a201473c408022d80c73f6ee7899 Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1760971 Tested-by: Tobias Bosch <tbosch@google.com> Reviewed-by: George Burgess <gbiv@chromium.org>
Diffstat (limited to 'compiler_wrapper/config.go')
-rw-r--r--compiler_wrapper/config.go179
1 files changed, 89 insertions, 90 deletions
diff --git a/compiler_wrapper/config.go b/compiler_wrapper/config.go
index 70d08c15..bd5786b6 100644
--- a/compiler_wrapper/config.go
+++ b/compiler_wrapper/config.go
@@ -27,8 +27,14 @@ type config struct {
mockOldWrapperCmds bool
// Directory to store errors that were prevented with -Wno-error.
newWarningsDir string
+ // Version. Only used for printing via -print-cmd.
+ version string
}
+// Version can be set via a linker flag.
+// Values fills config.version.
+var Version = ""
+
// OldWrapperPath can be set via a linker flag.
// Value fills config.oldWrapperPath.
var OldWrapperPath = ""
@@ -50,116 +56,109 @@ func getRealConfig() (*config, error) {
if err != nil {
return nil, wrapErrorwithSourceLocf(err, "invalid format for UseCCache")
}
- config, err := getConfig(useCCache, ConfigName, OldWrapperPath)
+ config, err := getConfig(ConfigName, useCCache, OldWrapperPath, Version)
if err != nil {
return nil, err
}
return config, nil
}
-func getConfig(useCCache bool, configName string, oldWrapperPath string) (*config, error) {
+func getConfig(configName string, useCCache bool, oldWrapperPath string, version string) (*config, error) {
+ var cfg *config
switch configName {
case "cros.hardened":
- return getCrosHardenedConfig(useCCache, oldWrapperPath), nil
+ cfg = crosHardenedConfig
case "cros.nonhardened":
- return getCrosNonHardenedConfig(useCCache, oldWrapperPath), nil
+ cfg = crosNonHardenedConfig
case "cros.host":
- return getCrosHostConfig(oldWrapperPath), nil
+ cfg = crosHostConfig
default:
return nil, newErrorwithSourceLocf("unknown config name: %s", configName)
}
+ cfg.useCCache = useCCache
+ cfg.oldWrapperPath = oldWrapperPath
+ cfg.version = version
+ return cfg, nil
}
// Full hardening.
-func getCrosHardenedConfig(useCCache bool, oldWrapperPath string) *config {
- // Temporarily disable function splitting because of chromium:434751.
- return &config{
- useCCache: useCCache,
- rootRelPath: "../../../../..",
- oldWrapperPath: oldWrapperPath,
- commonFlags: []string{
- "-fstack-protector-strong",
- "-fPIE",
- "-pie",
- "-D_FORTIFY_SOURCE=2",
- "-fno-omit-frame-pointer",
- },
- gccFlags: []string{
- "-fno-reorder-blocks-and-partition",
- "-Wno-unused-local-typedefs",
- "-Wno-maybe-uninitialized",
- },
- // Temporarily disable tautological-*-compare chromium:778316.
- // Temporarily add no-unknown-warning-option to deal with old clang versions.
- // Temporarily disable Wsection since kernel gets a bunch of these. chromium:778867
- // Disable "-faddrsig" since it produces object files that strip doesn't understand, chromium:915742.
- clangFlags: []string{
- "-Qunused-arguments",
- "-grecord-gcc-switches",
- "-fno-addrsig",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- "-Wno-section",
- "-static-libgcc",
- },
- newWarningsDir: "/tmp/fatal_clang_warnings",
- }
+// Temporarily disable function splitting because of chromium:434751.
+var crosHardenedConfig = &config{
+ rootRelPath: "../../../../..",
+ commonFlags: []string{
+ "-fstack-protector-strong",
+ "-fPIE",
+ "-pie",
+ "-D_FORTIFY_SOURCE=2",
+ "-fno-omit-frame-pointer",
+ },
+ gccFlags: []string{
+ "-fno-reorder-blocks-and-partition",
+ "-Wno-unused-local-typedefs",
+ "-Wno-maybe-uninitialized",
+ },
+ // Temporarily disable tautological-*-compare chromium:778316.
+ // Temporarily add no-unknown-warning-option to deal with old clang versions.
+ // Temporarily disable Wsection since kernel gets a bunch of these. chromium:778867
+ // Disable "-faddrsig" since it produces object files that strip doesn't understand, chromium:915742.
+ clangFlags: []string{
+ "-Qunused-arguments",
+ "-grecord-gcc-switches",
+ "-fno-addrsig",
+ "-Wno-tautological-constant-compare",
+ "-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-unknown-warning-option",
+ "-Wno-section",
+ "-static-libgcc",
+ },
+ newWarningsDir: "/tmp/fatal_clang_warnings",
}
// Flags to be added to non-hardened toolchain.
-func getCrosNonHardenedConfig(useCCache bool, oldWrapperPath string) *config {
- return &config{
- useCCache: useCCache,
- rootRelPath: "../../../../..",
- oldWrapperPath: oldWrapperPath,
- commonFlags: []string{},
- gccFlags: []string{
- "-Wno-maybe-uninitialized",
- "-Wno-unused-local-typedefs",
- "-Wno-deprecated-declarations",
- "-Wtrampolines",
- },
- // Temporarily disable tautological-*-compare chromium:778316.
- // Temporarily add no-unknown-warning-option to deal with old clang versions.
- // Temporarily disable Wsection since kernel gets a bunch of these. chromium:778867
- clangFlags: []string{
- "-Qunused-arguments",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- "-Wno-section",
- "-static-libgcc",
- },
- newWarningsDir: "/tmp/fatal_clang_warnings",
- }
+var crosNonHardenedConfig = &config{
+ rootRelPath: "../../../../..",
+ commonFlags: []string{},
+ gccFlags: []string{
+ "-Wno-maybe-uninitialized",
+ "-Wno-unused-local-typedefs",
+ "-Wno-deprecated-declarations",
+ "-Wtrampolines",
+ },
+ // Temporarily disable tautological-*-compare chromium:778316.
+ // Temporarily add no-unknown-warning-option to deal with old clang versions.
+ // Temporarily disable Wsection since kernel gets a bunch of these. chromium:778867
+ clangFlags: []string{
+ "-Qunused-arguments",
+ "-Wno-tautological-constant-compare",
+ "-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-unknown-warning-option",
+ "-Wno-section",
+ "-static-libgcc",
+ },
+ newWarningsDir: "/tmp/fatal_clang_warnings",
}
// Flags to be added to host toolchain.
-func getCrosHostConfig(oldWrapperPath string) *config {
- return &config{
- isHostWrapper: true,
- useCCache: false,
- rootRelPath: "../..",
- oldWrapperPath: oldWrapperPath,
- commonFlags: []string{},
- gccFlags: []string{
- "-Wno-maybe-uninitialized",
- "-Wno-unused-local-typedefs",
- "-Wno-deprecated-declarations",
- },
- // Temporarily disable tautological-*-compare chromium:778316.
- // Temporarily add no-unknown-warning-option to deal with old clang versions.
- clangFlags: []string{
- "-Qunused-arguments",
- "-grecord-gcc-switches",
- "-fno-addrsig",
- "-Wno-unused-local-typedefs",
- "-Wno-deprecated-declarations",
- "-Wno-tautological-constant-compare",
- "-Wno-tautological-unsigned-enum-zero-compare",
- "-Wno-unknown-warning-option",
- },
- newWarningsDir: "/tmp/fatal_clang_warnings",
- }
+var crosHostConfig = &config{
+ isHostWrapper: true,
+ rootRelPath: "../..",
+ commonFlags: []string{},
+ gccFlags: []string{
+ "-Wno-maybe-uninitialized",
+ "-Wno-unused-local-typedefs",
+ "-Wno-deprecated-declarations",
+ },
+ // Temporarily disable tautological-*-compare chromium:778316.
+ // Temporarily add no-unknown-warning-option to deal with old clang versions.
+ clangFlags: []string{
+ "-Qunused-arguments",
+ "-grecord-gcc-switches",
+ "-fno-addrsig",
+ "-Wno-unused-local-typedefs",
+ "-Wno-deprecated-declarations",
+ "-Wno-tautological-constant-compare",
+ "-Wno-tautological-unsigned-enum-zero-compare",
+ "-Wno-unknown-warning-option",
+ },
+ newWarningsDir: "/tmp/fatal_clang_warnings",
}