From 21d5c7aaa9e36ad80efbbbd573d627435984817c Mon Sep 17 00:00:00 2001 From: "Lukacs T. Berki" Date: Thu, 11 Mar 2021 08:52:39 +0100 Subject: [PATCH] Hard-wire the path to xcrun as /usr/bin/xcrun. This lets us not leak $PATH to soong_build. It was only needed for Darwin tests anyway. Test: Will ask jingwen@ who has a Mac. Change-Id: I4647e41275b323fe6283580f8f92718c6229f23e --- android/config.go | 19 ------------------- cc/config/x86_darwin_host.go | 2 +- ui/build/soong.go | 8 -------- 3 files changed, 1 insertion(+), 28 deletions(-) diff --git a/android/config.go b/android/config.go index ae4df1cb0..a9f01822b 100644 --- a/android/config.go +++ b/android/config.go @@ -527,25 +527,6 @@ func (c *config) HostJavaToolPath(ctx PathContext, path string) Path { return PathForOutput(ctx, "host", c.PrebuiltOS(), "framework", path) } -// NonHermeticHostSystemTool looks for non-hermetic tools from the system we're -// running on. These tools are not checked-in to AOSP, and therefore could lead -// to reproducibility problems. Should not be used for other than finding the -// XCode SDK (xcrun, sw_vers), etc. See ui/build/paths/config.go for the -// allowlist of host system tools. -func (c *config) NonHermeticHostSystemTool(name string) string { - for _, dir := range filepath.SplitList(c.Getenv("PATH")) { - path := filepath.Join(dir, name) - if s, err := os.Stat(path); err != nil { - continue - } else if m := s.Mode(); !s.IsDir() && m&0111 != 0 { - return path - } - } - panic(fmt.Errorf( - "Cannot find non-hermetic system tool '%s' on path '%s'", - name, c.Getenv("PATH"))) -} - // PrebuiltOS returns the name of the host OS used in prebuilts directories. func (c *config) PrebuiltOS() string { switch runtime.GOOS { diff --git a/cc/config/x86_darwin_host.go b/cc/config/x86_darwin_host.go index 1035df35b..b0344af84 100644 --- a/cc/config/x86_darwin_host.go +++ b/cc/config/x86_darwin_host.go @@ -136,7 +136,7 @@ var macTools = &macPlatformTools{} func getMacTools(ctx android.PackageVarContext) *macPlatformTools { macTools.once.Do(func() { - xcrunTool := ctx.Config().NonHermeticHostSystemTool("xcrun") + xcrunTool := "/usr/bin/xcrun" xcrun := func(args ...string) string { if macTools.err != nil { diff --git a/ui/build/soong.go b/ui/build/soong.go index 500abdac5..884e95741 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -177,14 +177,6 @@ func runSoong(ctx Context, config Config) { ninjaEnv.Set("TOP", os.Getenv("TOP")) ninjaEnv.Set("SOONG_OUTDIR", config.SoongOutDir()) - // Needed for NonHermeticHostSystemTool() and that, only in tests. We should - // probably find a better way of running tests other than making $PATH - // available also to production builds. Note that this is not get same as - // os.Getenv("PATH"): config.Environment() contains the $PATH that redirects - // every binary through the path interposer. - configPath, _ := config.Environment().Get("PATH") - ninjaEnv.Set("PATH", configPath) - // For debugging if os.Getenv("SOONG_DELVE") != "" { ninjaEnv.Set("SOONG_DELVE", os.Getenv("SOONG_DELVE"))