Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Call _beginthread(...) in C:\Program Files\Go\src\runtime\cgo #4081

Closed
TimurIskandarov opened this issue Sep 28, 2023 · 7 comments
Closed

Call _beginthread(...) in C:\Program Files\Go\src\runtime\cgo #4081

TimurIskandarov opened this issue Sep 28, 2023 · 7 comments
Labels
not-bug General questions, not an issue

Comments

@TimurIskandarov
Copy link

The sqlite3 driver is not built mattn/go-sqlite3#855

$ CGO_ENABLED=1 go install github.com/mattn/go-sqlite3
# runtime/cgo
gcc_libinit_windows.c: In function ‘_cgo_beginthread’:
gcc_libinit_windows.c:136:27: error: implicit declaration of function ‘_beginthread’; did you mean ‘_cgo_beginthread’? [-Werror=implicit-function-declaration]
  136 |                 thandle = _beginthread(func, 0, arg);
      |                           ^~~~~~~~~~~~
      |                           _cgo_beginthread
cc1: all warnings being treated as errors

It is called in the following files:

  • C:\Program Files\Go\src\runtime\cgo\gcc_libinit_windows.c\libcgo_windows.h
  • C:\Program Files\Go\src\runtime\cgo\gcc_libinit_windows.c

gcc (pacman -S gcc) searches for header files in directories:

 /usr/lib/gcc/x86_64-pc-msys/11.3.0/include
 /usr/lib/gcc/x86_64-pc-msys/11.3.0/include-fixed
 /usr/include
 /usr/lib/gcc/x86_64-pc-msys/11.3.0/../../../../lib/../include/w32api

process.h in /usr/include
windows.h -> /usr/include

This problem is not only related to the sqlite3 driver, it was also mentioned here golang/go#59490 (comment) and here https://stackoverflow.com/questions/75067559/how-to-fix-cgo-error-caused-by-race-flag

How can this be fixed? Maybe you need to somehow correct the names of the header files?

@Biswa96
Copy link
Member

Biswa96 commented Sep 28, 2023

"C:\Program Files\Go" is not provided by MSYS2.

gcc (pacman -S gcc) searches for header files in directories:

Use the mingw gcc.

@TimurIskandarov
Copy link
Author

@Biswa96 mingw-w64-go build sqlite driver?

@Biswa96
Copy link
Member

Biswa96 commented Sep 28, 2023

Please explain your question. I did not understand that.

@TimurIskandarov
Copy link
Author

will mingw-w64-go build?

@Biswa96
Copy link
Member

Biswa96 commented Sep 28, 2023

Feel free to try it.

@TimurIskandarov
Copy link
Author

Got it, I'll try it and report back

@TimurIskandarov
Copy link
Author

TimurIskandarov commented Sep 29, 2023

@Biswa96 pacman -s mingw-w64-x86_64-gcc works fine. I don't know why I didn't work out pacman -S gcc. Possibly due to MSYSTEM in settings.json VSCode.

    "terminal.integrated.profiles.windows": {
        // Add profile MSYS2
        "MSYS2": {
            "path": "C:\\msys64\\usr\\bin\\bash.exe",
            "args": ["--login", "-i"],
            "env": {
                "MSYSTEM": "MINGW64",
                "CHERE_INVOKING": "1",
                "MSYS2_PATH_TYPE": "inherit"
            },
            "overrideName": true
        },
        "PowerShell": null,
        "Git Bash": null,
    },
    "terminal.integrated.defaultProfile.windows": "MSYS2",

@Biswa96 Biswa96 closed this as completed Sep 29, 2023
@Biswa96 Biswa96 added the not-bug General questions, not an issue label Sep 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
not-bug General questions, not an issue
Projects
None yet
Development

No branches or pull requests

2 participants