golang.org/x/build@v0.0.0-20240506185731-218518f32b70/env/corellium/ios/files/clangwrap.go (about) 1 // Copyright 2019 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 //go:build ignore 6 7 // The clanghost binary is like clangwrap.sh but for self-hosted iOS. 8 // 9 // Use -ldflags="-X main.sdkpath=<path to iPhoneOS.sdk>" when building 10 // the wrapper. 11 package main 12 13 import ( 14 "fmt" 15 "os" 16 "os/exec" 17 ) 18 19 var sdkpath = "" 20 21 func main() { 22 if sdkpath == "" { 23 fmt.Fprintf(os.Stderr, "no SDK is set; use -ldflags=\"-X main.sdkpath=<sdk path>\" when building this wrapper.\n") 24 os.Exit(1) 25 } 26 args := os.Args[1:] 27 // Intercept requests for the path of the "ar" tool and instead 28 // always return "ar", so that the "ar" wrapper is used instead of 29 // /usr/bin/ar. See issue https://go.dev/issue/59221 and CL 30 // https://go.dev/cl/479775 for more detail. 31 if len(args) != 0 && args[0] == "--print-prog-name=ar" { 32 fmt.Printf("ar\n") 33 os.Exit(0) 34 } 35 cmd := exec.Command("clang", "-isysroot", sdkpath, "-mios-version-min=12.0") 36 cmd.Args = append(cmd.Args, args...) 37 cmd.Stdout = os.Stdout 38 cmd.Stderr = os.Stderr 39 if err := cmd.Run(); err != nil { 40 if err, ok := err.(*exec.ExitError); ok { 41 os.Exit(err.ExitCode()) 42 } 43 os.Exit(1) 44 } 45 os.Exit(0) 46 }