diff options
Diffstat (limited to 'vendor/modernc.org/sqlite')
-rw-r--r-- | vendor/modernc.org/sqlite/Makefile | 9 | ||||
-rw-r--r-- | vendor/modernc.org/sqlite/lib/hooks.go | 6 | ||||
-rw-r--r-- | vendor/modernc.org/sqlite/lib/hooks_linux_arm64.go | 30 | ||||
-rw-r--r-- | vendor/modernc.org/sqlite/sqlite.go | 5 | ||||
-rw-r--r-- | vendor/modernc.org/sqlite/vendor_libsqlite3.go | 126 |
5 files changed, 47 insertions, 129 deletions
diff --git a/vendor/modernc.org/sqlite/Makefile b/vendor/modernc.org/sqlite/Makefile index 8b7472ddd..e98811c34 100644 --- a/vendor/modernc.org/sqlite/Makefile +++ b/vendor/modernc.org/sqlite/Makefile @@ -37,8 +37,8 @@ build_all_targets: GOOS=linux GOARCH=riscv64 go build -v ./... GOOS=linux GOARCH=s390x go test -c -o /dev/null GOOS=linux GOARCH=s390x go build -v ./... - GOOS=netbsd GOARCH=amd64 go test -c -o /dev/null - GOOS=netbsd GOARCH=amd64 go build -v ./... + # GOOS=netbsd GOARCH=amd64 go test -c -o /dev/null + # GOOS=netbsd GOARCH=amd64 go build -v ./... GOOS=openbsd GOARCH=amd64 go test -c -o /dev/null GOOS=openbsd GOARCH=amd64 go build -v ./... GOOS=openbsd GOARCH=arm64 go test -c -o /dev/null @@ -69,7 +69,10 @@ test: go test -v -timeout 24h 2>&1 | tee log-test vendor: - go run vendor_libsqlite3.go && make build_all_targets + cd vendor_libsqlite3 && go build -o ../vendor main.go + ./vendor + rm -f vendor + make build_all_targets make build_all_targets work: diff --git a/vendor/modernc.org/sqlite/lib/hooks.go b/vendor/modernc.org/sqlite/lib/hooks.go index 9bedb87ac..4bd919b89 100644 --- a/vendor/modernc.org/sqlite/lib/hooks.go +++ b/vendor/modernc.org/sqlite/lib/hooks.go @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. +//go:build !(linux && arm64) + package sqlite3 import ( @@ -12,3 +14,7 @@ import ( func X__ccgo_sqlite3_log(t *libc.TLS, iErrCode int32, zFormat uintptr, va uintptr) { /* sqlite3.c:29405:17: */ libc.X__ccgo_sqlite3_log(t, iErrCode, zFormat, va) } + +func PatchIssue199() { + // nop +} diff --git a/vendor/modernc.org/sqlite/lib/hooks_linux_arm64.go b/vendor/modernc.org/sqlite/lib/hooks_linux_arm64.go new file mode 100644 index 000000000..be3873bf9 --- /dev/null +++ b/vendor/modernc.org/sqlite/lib/hooks_linux_arm64.go @@ -0,0 +1,30 @@ +// Copyright 2019 The Sqlite Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package sqlite3 + +import ( + "syscall" + "unsafe" + + "modernc.org/libc" +) + +// Format and write a message to the log if logging is enabled. +func X__ccgo_sqlite3_log(t *libc.TLS, iErrCode int32, zFormat uintptr, va uintptr) { /* sqlite3.c:29405:17: */ + libc.X__ccgo_sqlite3_log(t, iErrCode, zFormat, va) +} + +// https://gitlab.com/cznic/sqlite/-/issues/199 +// +// We are currently stuck on libc@v1.55.3. Until that is resolved - fix the +// problem at runtime. +func PatchIssue199() { + p := unsafe.Pointer(&_aSyscall) + *(*uintptr)(unsafe.Add(p, 608)) = __ccgo_fp(_unixGetpagesizeIssue199) +} + +func _unixGetpagesizeIssue199(tls *libc.TLS) (r int32) { + return int32(syscall.Getpagesize()) +} diff --git a/vendor/modernc.org/sqlite/sqlite.go b/vendor/modernc.org/sqlite/sqlite.go index 1af3eea7b..1e7e437ab 100644 --- a/vendor/modernc.org/sqlite/sqlite.go +++ b/vendor/modernc.org/sqlite/sqlite.go @@ -55,6 +55,11 @@ const ( sqliteLockedSharedcache = sqlite3.SQLITE_LOCKED | (1 << 8) ) +// https://gitlab.com/cznic/sqlite/-/issues/199 +func init() { + sqlite3.PatchIssue199() +} + // Error represents sqlite library error code. type Error struct { msg string diff --git a/vendor/modernc.org/sqlite/vendor_libsqlite3.go b/vendor/modernc.org/sqlite/vendor_libsqlite3.go deleted file mode 100644 index d7190ec4d..000000000 --- a/vendor/modernc.org/sqlite/vendor_libsqlite3.go +++ /dev/null @@ -1,126 +0,0 @@ -// Copyright 2024 The Sqlite Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build none -// +build none - -// Tool for 1.28+ -> 1.29+. Pulls adjusted libsqlite3 code to this repo. - -package main - -import ( - "bytes" - "fmt" - "go/token" - "os" - "path/filepath" - "strings" - - "modernc.org/gc/v3" -) - -func fail(rc int, msg string, args ...any) { - fmt.Fprintln(os.Stderr, strings.TrimSpace(fmt.Sprintf(msg, args...))) - os.Exit(rc) -} - -func main() { - for _, v := range []struct{ goos, goarch string }{ - {"darwin", "amd64"}, - {"darwin", "arm64"}, - {"freebsd", "amd64"}, - {"freebsd", "arm64"}, - {"linux", "386"}, - {"linux", "amd64"}, - {"linux", "arm"}, - {"linux", "arm64"}, - {"linux", "loong64"}, - {"linux", "ppc64le"}, - {"linux", "riscv64"}, - {"linux", "s390x"}, - {"windows", "386"}, - {"windows", "amd64"}, - } { - base := fmt.Sprintf("ccgo_%s_%s.go", v.goos, v.goarch) - if v.goos == "windows" && v.goarch == "amd64" { - base = "ccgo_windows.go" - } - ifn := filepath.Join("..", "libsqlite3", base) - fmt.Printf("%s/%s\t%s\n", v.goos, v.goarch, ifn) - in, err := os.ReadFile(ifn) - if err != nil { - fail(1, "%s\n", err) - } - - ast, err := gc.ParseFile(ifn, in) - if err != nil { - fail(1, "%s\n", err) - } - - b := bytes.NewBuffer(nil) - s := ast.SourceFile.PackageClause.Source(true) - s = strings.Replace(s, "package libsqlite3", "package sqlite3", 1) - fmt.Fprintln(b, s) - fmt.Fprint(b, ast.SourceFile.ImportDeclList.Source(true)) - taken := map[string]struct{}{} - for n := ast.SourceFile.TopLevelDeclList; n != nil; n = n.List { - switch x := n.TopLevelDecl.(type) { - case *gc.TypeDeclNode: - adn := x.TypeSpecList.TypeSpec.(*gc.AliasDeclNode) - nm := adn.IDENT.Src() - taken[nm] = struct{}{} - } - } - loop: - for n := ast.SourceFile.TopLevelDeclList; n != nil; n = n.List { - switch x := n.TopLevelDecl.(type) { - case *gc.ConstDeclNode: - switch y := x.ConstSpec.(type) { - case *gc.ConstSpecNode: - if y.IDENT.Src() != "SQLITE_TRANSIENT" { - fmt.Fprintln(b, x.Source(true)) - } - default: - panic(fmt.Sprintf("%v: %T %q", x.Position(), y, x.Source(false))) - } - - case *gc.FunctionDeclNode: - fmt.Fprintln(b, x.Source(true)) - case *gc.TypeDeclNode: - fmt.Fprintln(b, x.Source(true)) - adn := x.TypeSpecList.TypeSpec.(*gc.AliasDeclNode) - nm := adn.IDENT.Src() - nm2 := nm[1:] - if _, ok := taken[nm2]; ok { - break - } - - if token.IsExported(nm) { - fmt.Fprintf(b, "\ntype %s = %s\n", nm2, nm) - } - case *gc.VarDeclNode: - fmt.Fprintln(b, x.Source(true)) - default: - fmt.Printf("%v: TODO %T\n", n.Position(), x) - break loop - } - } - - b.WriteString(` -type Sqlite3_int64 = sqlite3_int64 -type Sqlite3_mutex_methods = sqlite3_mutex_methods -type Sqlite3_value = sqlite3_value - -type Sqlite3_index_info = sqlite3_index_info -type Sqlite3_module = sqlite3_module -type Sqlite3_vtab = sqlite3_vtab -type Sqlite3_vtab_cursor = sqlite3_vtab_cursor - -`) - base = strings.Replace(base, "ccgo_", "sqlite_", 1) - if err := os.WriteFile(filepath.Join("lib", base), b.Bytes(), 0660); err != nil { - fail(1, "%s\n", err) - } - } -} |