diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..c9839d6 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +*.a binary diff --git a/.github/workflows/build-v8-deps.yml b/.github/workflows/build-v8-deps.yml index 2afd46b..dcf3e92 100644 --- a/.github/workflows/build-v8-deps.yml +++ b/.github/workflows/build-v8-deps.yml @@ -101,6 +101,10 @@ jobs: # use custom libcxx for all cross-compiles to avoid system header conflicts USE_SYSROOT="false" USE_CUSTOM_LIBCXX="false" + IS_CLANG="true" + if [[ "${{ matrix.target_os }}" == "linux" && "${{ matrix.target_arch }}" == "amd64" ]]; then + IS_CLANG="false" + fi if [[ "${{ matrix.target_os }}" == "linux" && "${{ matrix.target_arch }}" == "arm64" ]]; then USE_SYSROOT="true" USE_CUSTOM_LIBCXX="true" @@ -111,13 +115,14 @@ jobs: cat > /tmp/gn_args.txt << EOF is_debug=false - is_clang=${{ matrix.target_os != 'linux' && 'true' || 'true' }} + is_clang=${IS_CLANG} target_os="${{ matrix.target_os == 'darwin' && 'mac' || matrix.target_os }}" target_cpu="${TARGET_CPU}" v8_target_cpu="${TARGET_CPU}" clang_use_chrome_plugins=false use_custom_libcxx=${USE_CUSTOM_LIBCXX} use_sysroot=${USE_SYSROOT} + use_thin_lto=false use_glib=false symbol_level=0 strip_debug_info=true @@ -168,7 +173,9 @@ jobs: import build build.args = Args() build.v8_path = os.path.join(os.getcwd(), 'v8') - build.is_clang = True + # Use system ar on Linux to produce GNU-format archives + # compatible with GNU ld (llvm-ar uses SysV64 format that ld rejects) + build.is_clang = ('${{ matrix.target_os }}' != 'linux') dest_path = os.path.join(os.getcwd(), '${{ matrix.target_os }}_${{ matrix.target_arch }}') os.makedirs(dest_path, exist_ok=True) diff --git a/.gitignore b/.gitignore index 05f61e4..827b308 100644 --- a/.gitignore +++ b/.gitignore @@ -11,3 +11,14 @@ coverage.out .idea/ .vscode/ .cursor + +# V8 local build artifacts (gclient/depot_tools) +deps/.cipd/ +deps/.gclient_entries +deps/.gclient_previous_* +deps/.gcs_entries +deps/__pycache__/ +deps/_bad_scm/ +deps/v8/ +deps/depot_tools/ +deps/.build/ diff --git a/cgo.go b/cgo.go index 93a2545..ffce290 100644 --- a/cgo.go +++ b/cgo.go @@ -3,6 +3,6 @@ package v8go //go:generate clang-format -i --verbose -style=Chromium v8go.h v8go.cc // #cgo CXXFLAGS: -fno-rtti -fPIC -std=c++20 -I${SRCDIR}/deps/include -Wall -// #cgo CXXFLAGS: -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH -DV8_ENABLE_SANDBOX +// #cgo CXXFLAGS: -DV8_COMPRESS_POINTERS -DV8_31BIT_SMIS_ON_64BIT_ARCH // #cgo CXXFLAGS: -DV8_DEPRECATION_WARNINGS -DV8_IMMINENT_DEPRECATION_WARNINGS import "C" diff --git a/deps/build.py b/deps/build.py index 171cd25..6c68a71 100644 --- a/deps/build.py +++ b/deps/build.py @@ -75,6 +75,7 @@ def get_custom_deps(): v8_target_cpu="%s" clang_use_chrome_plugins=false use_custom_libcxx=false +use_thin_lto=false use_sysroot=false use_glib=false symbol_level=%s diff --git a/deps/darwin_amd64/cgo.go b/deps/darwin_amd64/cgo.go new file mode 100644 index 0000000..6c28f62 --- /dev/null +++ b/deps/darwin_amd64/cgo.go @@ -0,0 +1,6 @@ +package darwin_amd64 + +// #cgo LDFLAGS: -pthread +// #cgo LDFLAGS: ${SRCDIR}/libv8-0.a ${SRCDIR}/libv8-1.a ${SRCDIR}/libv8-2.a +// #cgo LDFLAGS: -lc++ -framework CoreFoundation +import "C" diff --git a/deps/darwin_amd64/go.mod b/deps/darwin_amd64/go.mod new file mode 100644 index 0000000..8289c1c --- /dev/null +++ b/deps/darwin_amd64/go.mod @@ -0,0 +1,3 @@ +module github.com/tommie/v8go/deps/darwin_amd64 + +go 1.19 diff --git a/deps/darwin_amd64/libmanifest b/deps/darwin_amd64/libmanifest new file mode 100644 index 0000000..fbe1646 --- /dev/null +++ b/deps/darwin_amd64/libmanifest @@ -0,0 +1,3 @@ +libv8-0.a +libv8-1.a +libv8-2.a diff --git a/deps/darwin_amd64/libv8-0.a b/deps/darwin_amd64/libv8-0.a new file mode 100644 index 0000000..48f60fa Binary files /dev/null and b/deps/darwin_amd64/libv8-0.a differ diff --git a/deps/darwin_amd64/libv8-1.a b/deps/darwin_amd64/libv8-1.a new file mode 100644 index 0000000..2bad06f Binary files /dev/null and b/deps/darwin_amd64/libv8-1.a differ diff --git a/deps/darwin_amd64/libv8-2.a b/deps/darwin_amd64/libv8-2.a new file mode 100644 index 0000000..66f08d2 Binary files /dev/null and b/deps/darwin_amd64/libv8-2.a differ diff --git a/deps/darwin_amd64/vendor.go b/deps/darwin_amd64/vendor.go new file mode 100644 index 0000000..5930e91 --- /dev/null +++ b/deps/darwin_amd64/vendor.go @@ -0,0 +1 @@ +package darwin_amd64 diff --git a/deps/darwin_arm64/cgo.go b/deps/darwin_arm64/cgo.go new file mode 100644 index 0000000..526dad5 --- /dev/null +++ b/deps/darwin_arm64/cgo.go @@ -0,0 +1,6 @@ +package darwin_arm64 + +// #cgo LDFLAGS: -pthread +// #cgo LDFLAGS: ${SRCDIR}/libv8-0.a ${SRCDIR}/libv8-1.a +// #cgo LDFLAGS: -lc++ -framework CoreFoundation +import "C" diff --git a/deps/darwin_arm64/go.mod b/deps/darwin_arm64/go.mod new file mode 100644 index 0000000..7b1e993 --- /dev/null +++ b/deps/darwin_arm64/go.mod @@ -0,0 +1,3 @@ +module github.com/tommie/v8go/deps/darwin_arm64 + +go 1.19 diff --git a/deps/darwin_arm64/libmanifest b/deps/darwin_arm64/libmanifest new file mode 100644 index 0000000..54effa8 --- /dev/null +++ b/deps/darwin_arm64/libmanifest @@ -0,0 +1,2 @@ +libv8-0.a +libv8-1.a diff --git a/deps/darwin_arm64/libv8-0.a b/deps/darwin_arm64/libv8-0.a new file mode 100644 index 0000000..714991d Binary files /dev/null and b/deps/darwin_arm64/libv8-0.a differ diff --git a/deps/darwin_arm64/libv8-1.a b/deps/darwin_arm64/libv8-1.a new file mode 100644 index 0000000..5c44ea7 Binary files /dev/null and b/deps/darwin_arm64/libv8-1.a differ diff --git a/deps/darwin_arm64/vendor.go b/deps/darwin_arm64/vendor.go new file mode 100644 index 0000000..1cb58ab --- /dev/null +++ b/deps/darwin_arm64/vendor.go @@ -0,0 +1 @@ +package darwin_arm64 diff --git a/deps/linux_amd64/cgo.go b/deps/linux_amd64/cgo.go new file mode 100644 index 0000000..d94ae84 --- /dev/null +++ b/deps/linux_amd64/cgo.go @@ -0,0 +1,6 @@ +package linux_amd64 + +// #cgo LDFLAGS: -pthread +// #cgo LDFLAGS: -Wl,--start-group ${SRCDIR}/libv8-0.a ${SRCDIR}/libv8-1.a ${SRCDIR}/libv8-2.a -Wl,--end-group +// #cgo LDFLAGS: -ldl -lm -lstdc++ +import "C" diff --git a/deps/linux_amd64/go.mod b/deps/linux_amd64/go.mod new file mode 100644 index 0000000..8a52543 --- /dev/null +++ b/deps/linux_amd64/go.mod @@ -0,0 +1,3 @@ +module github.com/tommie/v8go/deps/linux_amd64 + +go 1.19 diff --git a/deps/linux_amd64/libmanifest b/deps/linux_amd64/libmanifest new file mode 100644 index 0000000..fbe1646 --- /dev/null +++ b/deps/linux_amd64/libmanifest @@ -0,0 +1,3 @@ +libv8-0.a +libv8-1.a +libv8-2.a diff --git a/deps/linux_amd64/libv8-0.a b/deps/linux_amd64/libv8-0.a new file mode 100644 index 0000000..a5457c4 Binary files /dev/null and b/deps/linux_amd64/libv8-0.a differ diff --git a/deps/linux_amd64/libv8-1.a b/deps/linux_amd64/libv8-1.a new file mode 100644 index 0000000..56d1d48 Binary files /dev/null and b/deps/linux_amd64/libv8-1.a differ diff --git a/deps/linux_amd64/libv8-2.a b/deps/linux_amd64/libv8-2.a new file mode 100644 index 0000000..a535a08 Binary files /dev/null and b/deps/linux_amd64/libv8-2.a differ diff --git a/deps/linux_amd64/vendor.go b/deps/linux_amd64/vendor.go new file mode 100644 index 0000000..5c3698b --- /dev/null +++ b/deps/linux_amd64/vendor.go @@ -0,0 +1 @@ +package linux_amd64 diff --git a/deps/linux_arm64/cgo.go b/deps/linux_arm64/cgo.go new file mode 100644 index 0000000..d637df2 --- /dev/null +++ b/deps/linux_arm64/cgo.go @@ -0,0 +1,6 @@ +package linux_arm64 + +// #cgo LDFLAGS: -pthread +// #cgo LDFLAGS: -Wl,--start-group ${SRCDIR}/libv8-0.a ${SRCDIR}/libv8-1.a ${SRCDIR}/libv8-2.a -Wl,--end-group +// #cgo LDFLAGS: -ldl -lm -lstdc++ +import "C" diff --git a/deps/linux_arm64/go.mod b/deps/linux_arm64/go.mod new file mode 100644 index 0000000..b63f863 --- /dev/null +++ b/deps/linux_arm64/go.mod @@ -0,0 +1,3 @@ +module github.com/tommie/v8go/deps/linux_arm64 + +go 1.19 diff --git a/deps/linux_arm64/libmanifest b/deps/linux_arm64/libmanifest new file mode 100644 index 0000000..fbe1646 --- /dev/null +++ b/deps/linux_arm64/libmanifest @@ -0,0 +1,3 @@ +libv8-0.a +libv8-1.a +libv8-2.a diff --git a/deps/linux_arm64/libv8-0.a b/deps/linux_arm64/libv8-0.a new file mode 100644 index 0000000..57a61ad Binary files /dev/null and b/deps/linux_arm64/libv8-0.a differ diff --git a/deps/linux_arm64/libv8-1.a b/deps/linux_arm64/libv8-1.a new file mode 100644 index 0000000..3204356 Binary files /dev/null and b/deps/linux_arm64/libv8-1.a differ diff --git a/deps/linux_arm64/libv8-2.a b/deps/linux_arm64/libv8-2.a new file mode 100644 index 0000000..eaac94a Binary files /dev/null and b/deps/linux_arm64/libv8-2.a differ diff --git a/deps/linux_arm64/vendor.go b/deps/linux_arm64/vendor.go new file mode 100644 index 0000000..a6c5a08 --- /dev/null +++ b/deps/linux_arm64/vendor.go @@ -0,0 +1 @@ +package linux_arm64 diff --git a/go.mod b/go.mod index 68e2fbd..f69cee0 100644 --- a/go.mod +++ b/go.mod @@ -10,3 +10,11 @@ require ( github.com/tommie/v8go/deps/linux_amd64 v0.0.0-20250515043113-5dcc98077472 github.com/tommie/v8go/deps/linux_arm64 v0.0.0-20250515043113-5dcc98077472 ) + +replace github.com/tommie/v8go/deps/darwin_amd64 => ./deps/darwin_amd64 + +replace github.com/tommie/v8go/deps/darwin_arm64 => ./deps/darwin_arm64 + +replace github.com/tommie/v8go/deps/linux_amd64 => ./deps/linux_amd64 + +replace github.com/tommie/v8go/deps/linux_arm64 => ./deps/linux_arm64