3
0
Fork 0
mirror of https://github.com/Z3Prover/z3 synced 2026-06-10 10:57:15 +00:00

Fix Go bindings compilation issues and add to CI

- Fix malformed z3.go with duplicate function body fragments
- Fix datatype.go to use Z3_del_constructor and Z3_del_constructor_list instead of non-existent inc_ref/dec_ref functions
- Remove non-existent Push/Pop methods from fixedpoint.go
- Fix CMake Go bindings targets quoting for proper LDFLAGS handling
- Add Go bindings support to ubuntu-cmake CI jobs

Co-authored-by: NikolajBjorner <3085284+NikolajBjorner@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-16 05:58:20 +00:00
parent c454b14c24
commit bbc1e501ab
4 changed files with 14 additions and 49 deletions

View file

@ -4,7 +4,7 @@
# Go bindings use CGO and are typically built using the Go toolchain directly.
# However, we can set up installation targets here.
if(BUILD_GO_BINDINGS)
if(Z3_BUILD_GO_BINDINGS)
message(STATUS "Z3 Go bindings will be installed")
# Install Go source files
@ -27,26 +27,29 @@ if(BUILD_GO_BINDINGS)
message(STATUS "Found Go: ${GO_EXECUTABLE}")
# Custom target to build Go bindings
set(CGO_LDFLAGS_VALUE "-L${CMAKE_BINARY_DIR} -lz3")
add_custom_target(go-bindings
COMMAND ${CMAKE_COMMAND} -E env
CGO_CFLAGS=-I${CMAKE_SOURCE_DIR}/src/api
CGO_LDFLAGS=-L${CMAKE_BINARY_DIR} -lz3
CGO_LDFLAGS=${CGO_LDFLAGS_VALUE}
${GO_EXECUTABLE} build -v
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
COMMENT "Building Go bindings"
DEPENDS libz3
VERBATIM
)
# Custom target to test Go examples
add_custom_target(test-go-examples
COMMAND ${CMAKE_COMMAND} -E env
CGO_CFLAGS=-I${CMAKE_SOURCE_DIR}/src/api
CGO_LDFLAGS=-L${CMAKE_BINARY_DIR} -lz3
CGO_LDFLAGS=${CGO_LDFLAGS_VALUE}
LD_LIBRARY_PATH=${CMAKE_BINARY_DIR}:$ENV{LD_LIBRARY_PATH}
PATH=${CMAKE_BINARY_DIR}\;$ENV{PATH}
PATH=${CMAKE_BINARY_DIR}$<SEMICOLON>$ENV{PATH}
${GO_EXECUTABLE} run ${CMAKE_SOURCE_DIR}/examples/go/basic_example.go
COMMENT "Running Go examples"
DEPENDS libz3
VERBATIM
)
else()
message(STATUS "Go not found - Go bindings can be built manually")