Make MinGW builds fully statically linked

Note the pthread usage is due to the Worker support, which is gated out
on Windows so there should be no need to link with pthreads on MinGW.
This commit is contained in:
Saúl Ibarra Corretgé 2023-11-22 15:44:13 +01:00
parent 5573681986
commit d88b6734e9
2 changed files with 6 additions and 3 deletions

View file

@ -250,6 +250,7 @@ jobs:
- name: stats - name: stats
run: | run: |
make stats make stats
ldd build/qjs
- name: test - name: test
run: | run: |
make test make test

View file

@ -132,9 +132,9 @@ if(BUILD_QJS_LIBC)
list(APPEND qjs_sources quickjs-libc.c) list(APPEND qjs_sources quickjs-libc.c)
endif() endif()
list(APPEND qjs_defines _GNU_SOURCE) list(APPEND qjs_defines _GNU_SOURCE)
list(APPEND qjs_libs qjs m pthread) list(APPEND qjs_libs qjs m)
if(NOT MINGW) if(NOT MINGW)
list(APPEND qjs_libs dl) list(APPEND qjs_libs dl pthread)
endif() endif()
add_library(qjs ${qjs_sources}) add_library(qjs ${qjs_sources})
@ -180,7 +180,9 @@ set_target_properties(qjs_exe PROPERTIES
) )
target_compile_definitions(qjs_exe PRIVATE ${qjs_defines}) target_compile_definitions(qjs_exe PRIVATE ${qjs_defines})
target_link_libraries(qjs_exe ${qjs_libs}) target_link_libraries(qjs_exe ${qjs_libs})
if(NOT MINGW) if(MINGW)
target_link_options(qjs_exe PRIVATE -static -static-libgcc)
else()
set_target_properties(qjs_exe PROPERTIES ENABLE_EXPORTS TRUE) set_target_properties(qjs_exe PROPERTIES ENABLE_EXPORTS TRUE)
endif() endif()