diff --git a/.github/workflows/go.yml b/.github/workflows/go.yml index 13b31da4..3ecb5f67 100644 --- a/.github/workflows/go.yml +++ b/.github/workflows/go.yml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - + - name: Set up Go uses: actions/setup-go@v5 with: @@ -115,12 +115,12 @@ jobs: run: | echo "Test result on ${{matrix.os}} with LLVM ${{matrix.llvm}}" > result.md bash .github/workflows/test_llgo.sh - + - name: chore/_xtool build tests run: | cd chore/_xtool llgo build -v ./... - + - name: LLDB tests if: ${{startsWith(matrix.os, 'macos')}} run: | @@ -128,8 +128,17 @@ jobs: bash _lldb/runtest.sh -v - name: Test demos - continue-on-error: true - run: bash .github/workflows/test_demo.sh + run: | + # TODO(lijie): force python3-embed to be linked with python-3.12-embed + # Currently, python3-embed is python-3.13-embed, doesn't work with pytorch + # Will remove this after pytorch is fixed. + pcdir=$HOME/pc + mkdir -p $pcdir + libdir=$(pkg-config --variable=libdir python-3.12-embed) + echo "libdir: $libdir" + ln -s $libdir/pkgconfig/python-3.12-embed.pc $pcdir/python3-embed.pc + export PKG_CONFIG_PATH=$pcdir + bash .github/workflows/test_demo.sh - name: Show test result run: cat result.md diff --git a/internal/build/cgo.go b/internal/build/cgo.go index 4443596b..9615a73b 100644 --- a/internal/build/cgo.go +++ b/internal/build/cgo.go @@ -188,11 +188,18 @@ func parseCgo_(pkg *aPackage, files []*ast.File) (cfiles []string, preambles []c dirs[dir] = none{} } for dir := range dirs { - files, err := filepath.Glob(filepath.Join(dir, "*.c")) + matches, err := filepath.Glob(filepath.Join(dir, "*.c")) if err != nil { continue } - cfiles = append(cfiles, files...) + for _, match := range matches { + if strings.HasSuffix(match, "_test.c") { + continue + } + if fi, err := os.Stat(match); err == nil && !fi.IsDir() { + cfiles = append(cfiles, match) + } + } } for _, file := range files { diff --git a/internal/lib/syscall/syscall_linux.go b/internal/lib/syscall/syscall_linux.go index ee097f35..9451443a 100644 --- a/internal/lib/syscall/syscall_linux.go +++ b/internal/lib/syscall/syscall_linux.go @@ -15,6 +15,7 @@ import ( _ "unsafe" "github.com/goplus/llgo/c" + "github.com/goplus/llgo/c/os" "github.com/goplus/llgo/c/syscall" ) @@ -114,7 +115,14 @@ func Pipe2(p []int, flags int) error { // ----------------------------------------------------------------------------- func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) { - panic("todo: syscall.Faccessat") + ret := faccessat(c.Int(dirfd), c.AllocaCStr(path), c.Int(mode), c.Int(flags)) + if ret != 0 { + return Errno(os.Errno()) + } + return nil } +//go:linkname faccessat C.faccessat +func faccessat(dirfd c.Int, path *c.Char, mode c.Int, flags c.Int) c.Int + // -----------------------------------------------------------------------------