Skip to content

Commit c87b9d3

Browse files
committed
auto merge of #11013 : klutzy/rust/win-no-pthread, r=alexcrichton
llvm supports both win32 native threads and pthread, but configure tries to find pthread first. This manually disables pthread to use native api. This removes libpthreads-2.dll dependency on librustc.
2 parents 6d2e61b + b0a9937 commit c87b9d3

File tree

7 files changed

+18
-505
lines changed

7 files changed

+18
-505
lines changed

configure

+4-2
Original file line numberDiff line numberDiff line change
@@ -910,9 +910,11 @@ do
910910
# Try to have LLVM pull in as few dependencies as possible (#9397)
911911
LLVM_OPTS="$LLVM_OPTS --disable-zlib --disable-libffi"
912912

913-
# pthreads works badly on mingw-w64 systems: #8996
913+
# Use win32 native thread/lock apis instead of pthread wrapper.
914+
# (llvm's configure tries to find pthread first, so we have to disable it explicitly.)
915+
# Also note that pthreads works badly on mingw-w64 systems: #8996
914916
case "$CFG_BUILD" in
915-
(*w64-mingw32)
917+
(*-mingw32)
916918
LLVM_OPTS="$LLVM_OPTS --disable-pthreads"
917919
;;
918920
esac

mk/llvm.mk

+1-2
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,7 @@ $(S)src/librustc/lib/llvmdeps.rs: \
5151
$(LLVM_CONFIGS) \
5252
$(S)src/etc/mklldeps.py
5353
$(Q)$(CFG_PYTHON) $(S)src/etc/mklldeps.py \
54-
"$(LLVM_COMPONENTS)" $(LLVM_CONFIGS) \
55-
> $@
54+
"$@" "$(LLVM_COMPONENTS)" $(LLVM_CONFIGS)
5655

5756
$(foreach host,$(CFG_HOST), \
5857
$(eval $(call DEF_LLVM_RULES,$(host))))

src/etc/mklldeps.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@
44
import sys
55
import subprocess
66

7-
components = sys.argv[1].split(' ')
7+
f = open(sys.argv[1], 'wb')
88

9-
print """// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
9+
components = sys.argv[2].split(' ')
10+
11+
f.write("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
1012
// file at the top-level directory of this distribution and at
1113
// http://rust-lang.org/COPYRIGHT.
1214
//
@@ -18,10 +20,10 @@
1820
1921
// WARNING: THIS IS A GENERATED FILE, DO NOT MODIFY
2022
// take a look at src/etc/mklldeps.py if you're interested
21-
"""
23+
""")
2224

23-
for llconfig in sys.argv[2:]:
24-
print
25+
for llconfig in sys.argv[3:]:
26+
f.write("\n")
2527

2628
proc = subprocess.Popen([llconfig, '--host-target'], stdout = subprocess.PIPE)
2729
out, err = proc.communicate()
@@ -42,7 +44,7 @@
4244
"target_os = \"" + os + "\"",
4345
]
4446

45-
print "#[cfg(" + ', '.join(cfg) + ")]"
47+
f.write("#[cfg(" + ', '.join(cfg) + ")]\n")
4648

4749
args = [llconfig, '--libs']
4850
args.extend(components)
@@ -51,8 +53,7 @@
5153

5254
for lib in out.strip().split(' '):
5355
lib = lib[2:] # chop of the leading '-l'
54-
print "#[link(name = \"" + lib + "\", kind = \"static\")]"
56+
f.write("#[link(name = \"" + lib + "\", kind = \"static\")]\n")
5557
if os == 'win32':
56-
print "#[link(name = \"pthread\")]"
57-
print "#[link(name = \"imagehlp\")]"
58-
print "extern {}"
58+
f.write("#[link(name = \"imagehlp\")]\n")
59+
f.write("extern {}\n")

src/etc/snapshot.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ def scrub(b):
3232
}
3333

3434
winnt_runtime_deps = ["libgcc_s_dw2-1.dll",
35-
"libstdc++-6.dll",
36-
"libpthread-2.dll"]
35+
"libstdc++-6.dll"]
3736

3837
def parse_line(n, line):
3938
global snapshotfile

0 commit comments

Comments
 (0)