Skip to content

Commit 0be01f6

Browse files
xavierleroydra27
authored andcommitted
Merge pull request #11586 from dra27/static-winpthreads
Remove dependency on libwinpthread-1.dll and GCC runtime library for mingw-w64 ports (cherry picked from commit cd36f15)
1 parent dcb4c83 commit 0be01f6

8 files changed

Lines changed: 19 additions & 44 deletions

File tree

Makefile.config.in

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -172,12 +172,6 @@ INSTALL_BYTECODE_PROGRAMS=@install_bytecode_programs@
172172
# systhreads Same as threads, requires POSIX threads
173173
OTHERLIBRARIES=@otherlibraries@
174174

175-
### Link-time options to ocamlc or ocamlopt for linking with POSIX threads
176-
# Needed for the "systhreads" package
177-
PTHREAD_LIBS=@PTHREAD_LIBS@
178-
PTHREAD_CAML_LIBS=$(addprefix -cclib ,$(PTHREAD_LIBS))
179-
PTHREAD_CFLAGS=@PTHREAD_CFLAGS@
180-
181175
UNIX_OR_WIN32=@unix_or_win32@
182176
INSTALL_SOURCE_ARTIFACTS=@install_source_artifacts@
183177

@@ -263,13 +257,3 @@ UNIXLIB=unix
263257
## Variables renamed in OCaml 4.13
264258

265259
RUNTIMEI=$(INSTRUMENTED_RUNTIME)
266-
267-
### pthread-related variables
268-
269-
PTHREAD_LINK=$(PTHREAD_LIBS)
270-
PTHREAD_CAML_LINK=$(PTHREAD_CAML_LIBS)
271-
272-
### It is expected that the value of PTHREAD_LINK changes between OCaml
273-
### 4.12 and 4.13. Indeed, for OCaml 4.12 most of the time the variable
274-
### contained -lpthread. From 4.13 onward it will most of the time be
275-
### empty since we have -pthread in CFLAGS which implies -lpthread.

configure

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,7 @@ AS_CASE([$arch,$system],
19061906

19071907
AS_CASE([$host],
19081908
[*-*-mingw32|*-pc-windows],
1909-
[PTHREAD_LIBS="-lpthread"],
1909+
[PTHREAD_LIBS="-l:libpthread.a"],
19101910
[AX_PTHREAD(
19111911
[common_cflags="$common_cflags $PTHREAD_CFLAGS"
19121912
saved_CFLAGS="$CFLAGS"
@@ -2098,8 +2098,8 @@ AC_CHECK_LIB(execinfo, backtrace, cclibs="$cclibs -lexecinfo",[])
20982098

20992099
AS_CASE([$host],
21002100
[*-*-mingw32],
2101-
[bytecclibs="-lws2_32 -lversion -lpthread -lgcc_eh -lDbgHelp"
2102-
nativecclibs="-lws2_32 -lversion -lpthread -lgcc_eh -lDbgHelp"],
2101+
[bytecclibs="-lws2_32 -lversion -l:libpthread.a -lgcc_eh -lDbgHelp"
2102+
nativecclibs="-lws2_32 -lversion -l:libpthread.a -lgcc_eh -lDbgHelp"],
21032103
[*-pc-windows],
21042104
[bytecclibs="advapi32.lib ws2_32.lib version.lib"
21052105
nativecclibs="advapi32.lib ws2_32.lib version.lib"],

otherlibs/str/Makefile

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ include ../Makefile.otherlibs.common
2424
str.cmo: str.cmi
2525
str.cmx: str.cmi
2626

27-
LDOPTS = $(PTHREAD_LINK)
28-
2927
.PHONY: depend
3028
depend:
3129
$(OCAMLRUN) $(ROOTDIR)/boot/ocamlc -depend -slash *.mli *.ml > .depend

otherlibs/systhreads/Makefile

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ ifneq "$(CCOMPTYPE)" "msvc"
2222
OC_CFLAGS += -g
2323
endif
2424

25-
OC_CFLAGS += $(SHAREDLIB_CFLAGS) $(PTHREAD_CFLAGS)
25+
OC_CFLAGS += $(SHAREDLIB_CFLAGS)
2626

2727
LIBS = $(STDLIBFLAGS) -I $(ROOTDIR)/otherlibs/unix
2828

@@ -59,27 +59,25 @@ all: lib$(LIBNAME).$(A) $(LIBNAME).cma $(CMIFILES)
5959
allopt: lib$(LIBNAME)nat.$(A) $(LIBNAME).cmxa $(CMIFILES)
6060

6161
lib$(LIBNAME).$(A): $(BYTECODE_C_OBJS)
62-
$(MKLIB_CMD) -o $(LIBNAME) $(BYTECODE_C_OBJS) $(PTHREAD_LIBS)
62+
$(MKLIB_CMD) -o $(LIBNAME) $(BYTECODE_C_OBJS)
6363

6464
lib$(LIBNAME)nat.$(A): $(NATIVECODE_C_OBJS)
6565
$(MKLIB_CMD) -o $(LIBNAME)nat $^
6666

6767
$(LIBNAME).cma: $(THREADS_BCOBJS)
6868
ifeq "$(UNIX_OR_WIN32)" "unix"
69-
$(MKLIB) -o $(LIBNAME) -ocamlc '$(CAMLC)' -cclib -lunix -linkall \
70-
$(PTHREAD_CAML_LIBS) $^
69+
$(MKLIB) -o $(LIBNAME) -ocamlc '$(CAMLC)' -cclib -lunix -linkall $^
7170
# TODO: Figure out why -cclib -lunix is used here.
7271
# It may be because of the threadsUnix module which is deprecated.
7372
# It may hence be good to figure out whether this module shouldn't be
7473
# removed, and then -cclib -lunix arguments.
7574
else # Windows
76-
$(MKLIB) -o $(LIBNAME) -ocamlc "$(CAMLC)" -linkall \
77-
$(PTHREAD_CAML_LIBS) $^
75+
$(MKLIB) -o $(LIBNAME) -ocamlc "$(CAMLC)" -linkall $^
7876
endif
7977

8078
# See remark above: force static linking of libthreadsnat.a
8179
$(LIBNAME).cmxa: $(THREADS_NCOBJS)
82-
$(CAMLOPT) -linkall -a -cclib -lthreadsnat $(PTHREAD_CAML_LIBS) -o $@ $^
80+
$(CAMLOPT) -linkall -a -cclib -lthreadsnat -o $@ $^
8381

8482
# Note: I removed "-cclib -lunix" from the line above.
8583
# Indeed, if we link threads.cmxa, then we must also link unix.cmxa,

otherlibs/systhreads/st_stubs.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,12 @@
1515

1616
#define CAML_INTERNALS
1717

18+
#if defined(_WIN32) && !defined(NATIVE_CODE)
19+
/* Ensure that pthread.h marks symbols __declspec(dllimport) so that they can be
20+
picked up from the runtime (which will have linked winpthreads statically) */
21+
#define DLL_EXPORT
22+
#endif
23+
1824
#include "caml/alloc.h"
1925
#include "caml/backtrace.h"
2026
#include "caml/backtrace_prim.h"

tools/ci/appveyor/appveyor_build.sh

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,15 +105,6 @@ if [[ $BOOTSTRAP_FLEXDLL = 'false' ]] ; then
105105
esac
106106
fi
107107

108-
# This is needed at all stages while winpthreads is in use for 5.0
109-
# This step can be moved back to the test phase (or removed entirely?) when
110-
# winpthreads stops being used.
111-
if [[ $PORT = 'mingw64' ]] ; then
112-
export PATH="$PATH:/usr/x86_64-w64-mingw32/sys-root/mingw/bin"
113-
elif [[ $PORT = 'mingw32' ]] ; then
114-
export PATH="$PATH:/usr/i686-w64-mingw32/sys-root/mingw/bin"
115-
fi
116-
117108
case "$1" in
118109
install)
119110
if [ ! -e "$CACHE_DIRECTORY/parallel-source" ] || \

tools/ci/inria/main

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,17 +170,15 @@ case "${OCAML_ARCH}" in
170170
instdir='C:/ocamlmgw'
171171
cleanup=true
172172
check_make_alldepend=true
173-
# This is needed until the winpthreads support is implemented directly
174-
export PATH="$PATH:/usr/i686-w64-mingw32/sys-root/mingw/bin"
173+
init_submodule=true
175174
;;
176175
mingw64)
177176
build='--build=x86_64-pc-cygwin'
178177
host='--host=x86_64-w64-mingw32'
179178
instdir='C:/ocamlmgw64'
180179
cleanup=true
181180
check_make_alldepend=true
182-
# This is needed until the winpthreads support is implemented directly
183-
export PATH="$PATH:/usr/x86_64-w64-mingw32/sys-root/mingw/bin"
181+
init_submodule=true
184182
;;
185183
msvc)
186184
build='--build=i686-pc-cygwin'

0 commit comments

Comments
 (0)