Repository: go
Issue: cmd/cgo: does not compile for iOS simulator arm64
Labels: help wanted,NeedsInvestigation,FeatureRequest,compiler/runtime

### What version of Go are you using (`go version`)?

<pre>
$ go version
go version go1.19.3 darwin/amd64
</pre>

### Does this issue reproduce with the latest release?
I am using the latest release


### What operating system and processor architecture are you using (`go env`)?

<details><summary><code>go env</code> Output</summary><br><pre>
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/Users/darioklepoch/Library/Caches/go-build"
GOENV="/Users/darioklepoch/Library/Application Support/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOINSECURE=""
GOMODCACHE="/Users/darioklepoch/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="darwin"
GOPATH="/Users/darioklepoch/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/local/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GOVCS=""
GOVERSION="go1.19.3"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="clang"
CXX="clang++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -arch x86_64 -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/d8/p77zrhr12g1_xc5y4bl_0rmh0000gn/T/go-build10530953=/tmp/go-build -gno-record-gcc-switches -fno-common"
</pre></details>

### What did you do?

I am trying to compile a go project to iOS c libraries and then create a xcframework out of those libraries.
This works great for iOS arm64 and simulator x86. However, when I try to compile for simulator arm64 I encounter problems.
The library built for arm64 simulator seems to not target the simulator but a real iOS device. This is problematic for using the simulator on new apple silicone devices.
I compiled using this command
``` make
ios-arm64:
	cd kagome; \
	CGO_ENABLED=1 \
	GOOS=darwin \
	GOARCH=arm64 \
	SDK=iphoneos \
	CC=$(PWD)/clangwrap.sh \
	CGO_CFLAGS="-fembed-bitcode" \
	go build -buildmode=c-archive -o ../$(OUT)/ios/kagome_dart_ios_arm64.a kagome.go

simulator-arm64:
	cd kagome; \
	CGO_ENABLED=1 \
	GOOS=darwin \
	GOARCH=arm64 \
	SDK=iphonesimulator \
	CGO_CFLAGS="-fembed-bitcode" \
	CC=$(PWD)/clangwrap.sh \
	go build -buildmode=c-archive -o ../$(OUT)/ios/kagome_dart_simulator_arm64.a kagome.go
```
and this is the `clangwrap.sh`

```bash
#!/bin/sh

# go/clangwrap.sh

SDK_PATH=`xcrun --sdk $SDK --show-sdk-path`
CLANG=`xcrun --sdk $SDK --find clang`

if [ "$GOARCH" == "amd64" ]; then
    CARCH="x86_64"
elif [ "$GOARCH" == "arm64" ]; then
    CARCH="arm64"
fi

exec $CLANG -arch $CARCH -isysroot $SDK_PATH -mios-version-min=10.0 "$@"
```

When now creating a xcframework 
``` bash
xcodebuild -create-xcframework \
		-library $(OUT)/ios/kagome_dart_simulator_arm64.a \
		-library $(OUT)/ios/kagome_dart_ios_arm64.a \
		-output  $(OUT)/ios/kagome_dart.xcframework
```

the error is
```
A library with the identifier 'ios-arm64' already exists.
```

### What did you expect to see?
I expected the library to be built for an arm64 simulator.


### What did you see instead?
The library was built for an arm64 iOS device.