purego: clean up some code (#123)
- commit
- e1459079498f0551770af3cedc2903b3f3e3c7b2
- author
- Hajime Hoshi · · 2023-04-03 19:33 UTC
- committer
- GitHub · · 2023-04-03 19:33 UTC
- parent
- b4a1f66
- signature
- GPG Unverified
4AEE18F83AFDEB23The key is unknown - refs
- tag: v0.4.0-alpha.2
1 file · +2 -3
M dlfcn_test.go +2 -3
| @@ -129,9 +129,8 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | |||
| 129 | 129 | // macOS arm64 can run amd64 tests through Rossetta. | |
| 130 | 130 | // Build the shared library based on the GOARCH and not | |
| 131 | 131 | // the default behavior of the compiler. | |
| 132 | - | var archFlag, arch string | |
| 133 | 132 | if runtime.GOOS == "darwin" { | |
| 134 | - | archFlag = "-arch" | |
| 133 | + | var arch string | |
| 135 | 134 | switch runtime.GOARCH { | |
| 136 | 135 | case "arm64": | |
| 137 | 136 | arch = "arm64" | |
| @@ -140,7 +139,7 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | |||
| 140 | 139 | default: | |
| 141 | 140 | return fmt.Errorf("unknown macOS architecture %s", runtime.GOARCH) | |
| 142 | 141 | } | |
| 143 | - | args = append(args, archFlag, arch) | |
| 142 | + | args = append(args, "-arch", arch) | |
| 144 | 143 | } | |
| 145 | 144 | cmd := exec.Command(compiler, append(args, sources...)...) | |
| 146 | 145 | if out, err := cmd.CombinedOutput(); err != nil { | |
| @@ -129,9 +129,8 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | |||||
| 129 | // macOS arm64 can run amd64 tests through Rossetta. | 129 | // macOS arm64 can run amd64 tests through Rossetta. | ||
| 130 | // Build the shared library based on the GOARCH and not | 130 | // Build the shared library based on the GOARCH and not | ||
| 131 | // the default behavior of the compiler. | 131 | // the default behavior of the compiler. | ||
| 132 | - | var archFlag, arch string | |||
| 133 | if runtime.GOOS == "darwin" { | 132 | if runtime.GOOS == "darwin" { | ||
| 134 | - | archFlag = "-arch" | 133 | + | var arch string |
| 135 | switch runtime.GOARCH { | 134 | switch runtime.GOARCH { | ||
| 136 | case "arm64": | 135 | case "arm64": | ||
| 137 | arch = "arm64" | 136 | arch = "arm64" | ||
| @@ -140,7 +139,7 @@ func buildSharedLib(compilerEnv, libFile string, sources ...string) error { | |||||
| 140 | default: | 139 | default: | ||
| 141 | return fmt.Errorf("unknown macOS architecture %s", runtime.GOARCH) | 140 | return fmt.Errorf("unknown macOS architecture %s", runtime.GOARCH) | ||
| 142 | } | 141 | } | ||
| 143 | - | args = append(args, archFlag, arch) | 142 | + | args = append(args, "-arch", arch) |
| 144 | } | 143 | } | ||
| 145 | cmd := exec.Command(compiler, append(args, sources...)...) | 144 | cmd := exec.Command(compiler, append(args, sources...)...) | ||
| 146 | if out, err := cmd.CombinedOutput(); err != nil { | 145 | if out, err := cmd.CombinedOutput(); err != nil { | ||