File tree Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Expand file tree Collapse file tree 4 files changed +25
-7
lines changed Original file line number Diff line number Diff line change @@ -388,6 +388,7 @@ opt ccache 0 "invoke gcc/clang via ccache to reuse object files between builds"
388
388
opt local-rust 0 " use an installed rustc rather than downloading a snapshot"
389
389
opt pax-flags 0 " apply PaX flags to rustc binaries (required for GRSecurity/PaX-patched kernels)"
390
390
opt inject-std-version 1 " inject the current compiler version of libstd into programs"
391
+ opt llvm-static-stdcpp 0 " statically link to libstdc++ for LLVM"
391
392
opt rpath 1 " build rpaths into rustc itself"
392
393
opt nightly 0 " build nightly packages"
393
394
opt verify-install 1 " verify installed binaries work"
Original file line number Diff line number Diff line change @@ -42,16 +42,25 @@ $$(LLVM_STAMP_$(1)): $(S)src/rustllvm/llvm-auto-clean-trigger
42
42
@$$(call E, make: done cleaning llvm)
43
43
touch $$@
44
44
45
+ ifeq ($$(CFG_ENABLE_LLVM_STATIC_STDCPP ) ,1)
46
+ LLVM_STDCPP_LOCATION_$(1) = $$(shell $$(CC_$(1 ) ) $$(CFG_GCCISH_CFLAGS_$(1 ) ) \
47
+ -print-file-name=libstdc++.a)
48
+ else
49
+ LLVM_STDCPP_LOCATION_$(1) =
50
+ endif
51
+
45
52
endef
46
53
47
54
$(foreach host,$(CFG_HOST), \
48
- $(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_ $(host))))
55
+ $(eval $(call DEF_LLVM_RULES, $(host))))
49
56
50
57
$(foreach host,$(CFG_HOST), \
51
- $(eval $(call DEF_LLVM_RULES, $(host))))
58
+ $(eval LLVM_CONFIGS := $(LLVM_CONFIGS) $(LLVM_CONFIG_ $(host))))
52
59
53
60
$(S ) src/librustc/lib/llvmdeps.rs : \
54
61
$(LLVM_CONFIGS ) \
55
- $(S ) src/etc/mklldeps.py
62
+ $(S ) src/etc/mklldeps.py \
63
+ $(MKFILE_DEPS )
56
64
$(Q )$(CFG_PYTHON ) $(S ) src/etc/mklldeps.py \
57
- " $@ " " $( LLVM_COMPONENTS) " $(LLVM_CONFIGS )
65
+ " $@ " " $( LLVM_COMPONENTS) " " $( CFG_ENABLE_LLVM_STATIC_STDCPP) " \
66
+ $(LLVM_CONFIGS )
Original file line number Diff line number Diff line change @@ -83,6 +83,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
83
83
$$(WFLAGS_ST$(1 ) ) \
84
84
-L "$$(RT_OUTPUT_DIR_$(2 ) ) " \
85
85
-L "$$(LLVM_LIBDIR_$(2 ) ) " \
86
+ -L "$$(dir $$(LLVM_STDCPP_LOCATION_$(2 ) ) ) " \
86
87
--out-dir $$(@D ) $$<
87
88
@touch $$@
88
89
$$(call LIST_ALL_OLD_GLOB_MATCHES,\
Original file line number Diff line number Diff line change 11
11
import os
12
12
import sys
13
13
import subprocess
14
+ import itertools
15
+ from os import path
14
16
15
17
f = open (sys .argv [1 ], 'wb' )
16
18
17
19
components = sys .argv [2 ].split (' ' )
18
20
components = [i for i in components if i ] # ignore extra whitespaces
21
+ enable_static = sys .argv [3 ]
19
22
20
23
f .write ("""// Copyright 2013 The Rust Project Developers. See the COPYRIGHT
21
24
// file at the top-level directory of this distribution and at
@@ -41,7 +44,7 @@ def run(args):
41
44
sys .exit (1 )
42
45
return out
43
46
44
- for llconfig in sys .argv [3 :]:
47
+ for llconfig in sys .argv [4 :]:
45
48
f .write ("\n " )
46
49
47
50
out = run ([llconfig , '--host-target' ])
@@ -94,9 +97,13 @@ def run(args):
94
97
95
98
# C++ runtime library
96
99
out = run ([llconfig , '--cxxflags' ])
97
- if 'stdlib=libc++' in out :
98
- f .write ("#[link(name = \" c++\" )]\n " )
100
+ if enable_static == '1' :
101
+ assert ('stdlib=libc++' not in out )
102
+ f .write ("#[link(name = \" stdc++\" , kind = \" static\" )]\n " )
99
103
else :
104
+ if 'stdlib=libc++' in out :
105
+ f .write ("#[link(name = \" c++\" )]\n " )
106
+ else :
100
107
f .write ("#[link(name = \" stdc++\" )]\n " )
101
108
102
109
# Attach everything to an extern block
You can’t perform that action at this time.
0 commit comments