diff options
author | Tobias Bosch <tbosch@google.com> | 2019-08-14 15:15:21 -0700 |
---|---|---|
committer | Tobias Bosch <tbosch@google.com> | 2019-08-15 22:43:02 +0000 |
commit | 47f580fe94bc41a39c010559c78d918d6fabc2db (patch) | |
tree | 647875f5d14254992055c299de93490218e459b1 /compiler_wrapper/config.go | |
parent | 5fa6d24a85e04ee967f277369ba3714a4a6efe3b (diff) | |
download | toolchain-utils-47f580fe94bc41a39c010559c78d918d6fabc2db.tar.gz |
Pass the old wrapper path as a linker argument
BUG=chromium:773875
TEST=unit test and comparison to old wrapper
Change-Id: I97cff81f2b42a01f82ba66668693b17a27c14672
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/toolchain-utils/+/1754130
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.go | 26 |
1 files changed, 15 insertions, 11 deletions
diff --git a/compiler_wrapper/config.go b/compiler_wrapper/config.go index 7567d0e2..70d08c15 100644 --- a/compiler_wrapper/config.go +++ b/compiler_wrapper/config.go @@ -29,6 +29,10 @@ type config struct { newWarningsDir string } +// OldWrapperPath can be set via a linker flag. +// Value fills config.oldWrapperPath. +var OldWrapperPath = "" + // UseCCache can be set via a linker flag. // Value will be passed to strconv.ParseBool. // E.g. go build -ldflags '-X config.UseCCache=true'. @@ -46,33 +50,33 @@ func getRealConfig() (*config, error) { if err != nil { return nil, wrapErrorwithSourceLocf(err, "invalid format for UseCCache") } - config, err := getConfig(useCCache, ConfigName) + config, err := getConfig(useCCache, ConfigName, OldWrapperPath) if err != nil { return nil, err } return config, nil } -func getConfig(useCCache bool, configName string) (*config, error) { +func getConfig(useCCache bool, configName string, oldWrapperPath string) (*config, error) { switch configName { case "cros.hardened": - return getCrosHardenedConfig(useCCache), nil + return getCrosHardenedConfig(useCCache, oldWrapperPath), nil case "cros.nonhardened": - return getCrosNonHardenedConfig(useCCache), nil + return getCrosNonHardenedConfig(useCCache, oldWrapperPath), nil case "cros.host": - return getCrosHostConfig(), nil + return getCrosHostConfig(oldWrapperPath), nil default: return nil, newErrorwithSourceLocf("unknown config name: %s", configName) } } // Full hardening. -func getCrosHardenedConfig(useCCache bool) *config { +func getCrosHardenedConfig(useCCache bool, oldWrapperPath string) *config { // Temporarily disable function splitting because of chromium:434751. return &config{ useCCache: useCCache, rootRelPath: "../../../../..", - oldWrapperPath: "./sysroot_wrapper.hardened.old", + oldWrapperPath: oldWrapperPath, commonFlags: []string{ "-fstack-protector-strong", "-fPIE", @@ -104,11 +108,11 @@ func getCrosHardenedConfig(useCCache bool) *config { } // Flags to be added to non-hardened toolchain. -func getCrosNonHardenedConfig(useCCache bool) *config { +func getCrosNonHardenedConfig(useCCache bool, oldWrapperPath string) *config { return &config{ useCCache: useCCache, rootRelPath: "../../../../..", - oldWrapperPath: "./sysroot_wrapper.old", + oldWrapperPath: oldWrapperPath, commonFlags: []string{}, gccFlags: []string{ "-Wno-maybe-uninitialized", @@ -132,12 +136,12 @@ func getCrosNonHardenedConfig(useCCache bool) *config { } // Flags to be added to host toolchain. -func getCrosHostConfig() *config { +func getCrosHostConfig(oldWrapperPath string) *config { return &config{ isHostWrapper: true, useCCache: false, rootRelPath: "../..", - oldWrapperPath: "./host_wrapper.old", + oldWrapperPath: oldWrapperPath, commonFlags: []string{}, gccFlags: []string{ "-Wno-maybe-uninitialized", |