Skip to content

Commit d6b2252

Browse files
committed
Fix the macos cross build within the OCP builder image
Fix the cross-compilation issue without disabling CGO. The problem was that the macOS SDK 10.15 in the builder image doesn't have the SecTrustCopyCertificateChain symbol that Go 1.25's crypto/x509 package requires (this API was introduced in macOS 12.0). Use the -Wl,-undefined,dynamic_lookup linker flag for macOS cross-compilation. This tells the linker to allow undefined symbols that will be resolved at runtime. The alternative would be to disable CGO. Signed-off-by: Todd Short <[email protected]> Assisted by: Claude Code
1 parent 423abca commit d6b2252

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ $(COLLECT_PROFILES_CMD): FORCE
101101
cross: version_flags=-X '$(REGISTRY_PKG)/cmd/opm/version.gitCommit=$(GIT_COMMIT)' -X '$(REGISTRY_PKG)/cmd/opm/version.opmVersion=$(OPM_VERSION)' -X '$(REGISTRY_PKG)/cmd/opm/version.buildDate=$(BUILD_DATE)'
102102
cross:
103103
ifeq ($(shell go env GOARCH),amd64)
104-
GOOS=darwin CC=o64-clang CXX=o64-clang++ CGO_ENABLED=1 go build $(GO_BUILD_OPTS) $(GO_BUILD_TAGS) -o "bin/darwin-amd64-opm" --ldflags "-extld=o64-clang $(version_flags)" $(REGISTRY_PKG)/cmd/opm
104+
GOOS=darwin CC=o64-clang CXX=o64-clang++ CGO_ENABLED=1 CGO_LDFLAGS='-Wl,-undefined,dynamic_lookup' go build $(GO_BUILD_OPTS) $(GO_BUILD_TAGS) -o "bin/darwin-amd64-opm" --ldflags "-extld=o64-clang -extldflags=-Wl,-undefined,dynamic_lookup $(version_flags)" $(REGISTRY_PKG)/cmd/opm
105105
GOOS=windows CC=x86_64-w64-mingw32-gcc CXX=x86_64-w64-mingw32-g++ CGO_ENABLED=1 go build $(GO_BUILD_OPTS) $(GO_BUILD_TAGS) -o "bin/windows-amd64-opm" --ldflags "-extld=x86_64-w64-mingw32-gcc $(version_flags)" -buildmode=exe $(REGISTRY_PKG)/cmd/opm
106106
endif
107107

0 commit comments

Comments
 (0)