Skip to content

Commit e338a41

Browse files
committed
Add generation of static libraries to rustc
This commit implements the support necessary for generating both intermediate and result static rust libraries. This is an implementation of my thoughts in https://mail.mozilla.org/pipermail/rust-dev/2013-November/006686.html. When compiling a library, we still retain the "lib" option, although now there are "rlib", "staticlib", and "dylib" as options for crate_type (and these are stackable). The idea of "lib" is to generate the "compiler default" instead of having too choose (although all are interchangeable). For now I have left the "complier default" to be a dynamic library for size reasons. Of the rust libraries, lib{std,extra,rustuv} will bootstrap with an rlib/dylib pair, but lib{rustc,syntax,rustdoc,rustpkg} will only be built as a dynamic object. I chose this for size reasons, but also because you're probably not going to be embedding the rustc compiler anywhere any time soon. Other than the options outlined above, there are a few defaults/preferences that are now opinionated in the compiler: * If both a .dylib and .rlib are found for a rust library, the compiler will prefer the .rlib variant. This is overridable via the -Z prefer-dynamic option * If generating a "lib", the compiler will generate a dynamic library. This is overridable by explicitly saying what flavor you'd like (rlib, staticlib, dylib). * If no options are passed to the command line, and no crate_type is found in the destination crate, then an executable is generated With this change, you can successfully build a rust program with 0 dynamic dependencies on rust libraries. There is still a dynamic dependency on librustrt, but I plan on removing that in a subsequent commit. This change includes no tests just yet. Our current testing infrastructure/harnesses aren't very amenable to doing flavorful things with linking, so I'm planning on adding a new mode of testing which I believe belongs as a separate commit. Closes #552
1 parent 80991bb commit e338a41

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1154
-639
lines changed

Makefile.in

+31-36
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,14 @@ ifndef DEBUG_BORROWS
130130
RUSTFLAGS_STAGE2 += -Z no-debug-borrows
131131
endif
132132

133+
# The executables crated during this compilation process have no need to include
134+
# static copies of libstd and libextra. We also generate dynamic versions of all
135+
# libraries, so in the interest of space, prefer dynamic linking throughout the
136+
# compilation process.
137+
RUSTFLAGS_STAGE1 += -Z prefer-dynamic
138+
RUSTFLAGS_STAGE2 += -Z prefer-dynamic
139+
RUSTFLAGS_STAGE3 += -Z prefer-dynamic
140+
133141
# platform-specific auto-configuration
134142
include $(CFG_SRC_DIR)mk/platform.mk
135143

@@ -239,6 +247,10 @@ LIBRUSTPKG_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustpkg)
239247
LIBRUSTDOC_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustdoc)
240248
LIBRUSTUV_DSYM_GLOB_$(1) :=$(call CFG_LIB_DSYM_GLOB_$(1),rustuv)
241249

250+
EXTRALIB_RGLOB_$(1) :=$(call CFG_RLIB_GLOB,extra)
251+
STDLIB_RGLOB_$(1) :=$(call CFG_RLIB_GLOB,std)
252+
LIBRUSTUV_RGLOB_$(1) :=$(call CFG_RLIB_GLOB,rustuv)
253+
242254
endef
243255

244256
# $(1) is the path for directory to match against
@@ -392,42 +404,25 @@ TBIN$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/bin
392404
TLIB$(1)_T_$(2)_H_$(3) = $$(TROOT$(1)_T_$(2)_H_$(3))/$$(CFG_LIBDIR)
393405

394406
# The name of the standard and extra libraries used by rustc
395-
ifdef CFG_DISABLE_SHAREDSTD
396-
HSTDLIB_DEFAULT$(1)_H_$(3) = \
397-
$$(HLIB$(1)_H_$(3))/libstd.rlib
398-
TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
399-
$$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
400-
401-
HEXTRALIB_DEFAULT$(1)_H_$(3) = \
402-
$$(HLIB$(1)_H_$(3))/libextra.rlib
403-
TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
404-
$$(TLIB$(1)_T_$(2)_H_$(3))/libextra.rlib
405-
406-
HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
407-
$$(HLIB$(1)_H_$(3))/librustc.rlib
408-
TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
409-
$$(TLIB$(1)_T_$(2)_H_$(3))/librustc.rlib
410-
else
411-
HSTDLIB_DEFAULT$(1)_H_$(3) = \
412-
$$(HLIB$(1)_H_$(3))/$(CFG_STDLIB_$(3))
413-
TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
414-
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2))
415-
416-
HEXTRALIB_DEFAULT$(1)_H_$(3) = \
417-
$$(HLIB$(1)_H_$(3))/$(CFG_EXTRALIB_$(3))
418-
TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
419-
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
420-
421-
HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
422-
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC_$(3))
423-
TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
424-
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2))
425-
426-
HLIBRUSTUV_DEFAULT$(1)_H_$(3) = \
427-
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTUV_$(3))
428-
TLIBRUSTUV_DEFAULT$(1)_T_$(2)_H_$(3) = \
429-
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2))
430-
endif
407+
HSTDLIB_DEFAULT$(1)_H_$(3) = \
408+
$$(HLIB$(1)_H_$(3))/$(CFG_STDLIB_$(3))
409+
TSTDLIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
410+
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2))
411+
412+
HEXTRALIB_DEFAULT$(1)_H_$(3) = \
413+
$$(HLIB$(1)_H_$(3))/$(CFG_EXTRALIB_$(3))
414+
TEXTRALIB_DEFAULT$(1)_T_$(2)_H_$(3) = \
415+
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2))
416+
417+
HLIBRUSTC_DEFAULT$(1)_H_$(3) = \
418+
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTC_$(3))
419+
TLIBRUSTC_DEFAULT$(1)_T_$(2)_H_$(3) = \
420+
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2))
421+
422+
HLIBRUSTUV_DEFAULT$(1)_H_$(3) = \
423+
$$(HLIB$(1)_H_$(3))/$(CFG_LIBRUSTUV_$(3))
424+
TLIBRUSTUV_DEFAULT$(1)_T_$(2)_H_$(3) = \
425+
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2))
431426

432427
# Preqrequisites for using the stageN compiler
433428
HSREQ$(1)_H_$(3) = \

configure

+1-2
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,6 @@ fi
364364
BOOL_OPTIONS=""
365365
VAL_OPTIONS=""
366366

367-
opt sharedstd 1 "build libstd as a shared library"
368367
opt valgrind 0 "run tests with valgrind (memcheck by default)"
369368
opt helgrind 0 "run tests with helgrind instead of memcheck"
370369
opt docs 1 "build documentation"
@@ -398,7 +397,7 @@ valopt sysconfdir "/etc" "install system configuration files"
398397
valopt datadir "${CFG_PREFIX}/share" "install data"
399398
valopt infodir "${CFG_PREFIX}/share/info" "install additional info"
400399
valopt mandir "${CFG_PREFIX}/share/man" "install man pages in PATH"
401-
valopt libdir "${CFG_PREFIX}/lib" "install libraries"
400+
valopt libdir "${CFG_PREFIX}/lib" "install libraries"
402401

403402
# Validate Options
404403
step_msg "validating $CFG_SELF args"

doc/rust.md

+4-8
Original file line numberDiff line numberDiff line change
@@ -1507,19 +1507,15 @@ an `abi` string, as shown here:
15071507
extern "stdcall" { }
15081508
~~~~
15091509

1510-
The `link_name` attribute allows the name of the library to be specified.
1510+
The `link` attribute allows the name of the library to be specified. When
1511+
specified the compiler will attempt to link against the native library of the
1512+
specified name.
15111513

15121514
~~~~ {.xfail-test}
1513-
#[link_name = "crypto"]
1515+
#[link(name = "crypto")]
15141516
extern { }
15151517
~~~~
15161518

1517-
The `nolink` attribute tells the Rust compiler
1518-
not to do any linking for the external block.
1519-
This is particularly useful for creating external blocks for libc,
1520-
which tends to not follow standard library naming conventions
1521-
and is linked to all Rust programs anyway.
1522-
15231519
The type of a function
15241520
declared in an extern block
15251521
is `extern "abi" fn(A1, ..., An) -> R`,

mk/clean.mk

+8-2
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ clean-generic-$(2)-$(1):
5959
$(Q)find $(1)/rustllvm \
6060
$(1)/rt \
6161
$(1)/test \
62+
$(1)/stage* \
6263
-name '*.[odasS]' -o \
6364
-name '*.so' -o \
6465
-name '*.dylib' -o \
@@ -91,13 +92,16 @@ clean$(1)_H_$(2):
9192
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBRUSTC_$(2))
9293
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_LIBSYNTAX_$(2))
9394
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(STDLIB_GLOB_$(2))
95+
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(STDLIB_RGLOB_$(2))
9496
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(EXTRALIB_GLOB_$(2))
97+
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(EXTRALIB_RGLOB_$(2))
98+
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBRUSTUV_GLOB_$(2))
99+
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBRUSTUV_RGLOB_$(2))
95100
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBRUSTC_GLOB_$(2))
96101
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBSYNTAX_GLOB_$(2))
97102
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBRUSTPKG_GLOB_$(2))
98103
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(LIBRUSTDOC_GLOB_$(2))
99104
$(Q)rm -f $$(HLIB$(1)_H_$(2))/$(CFG_RUSTLLVM_$(2))
100-
$(Q)rm -f $$(HLIB$(1)_H_$(2))/libstd.rlib
101105

102106
endef
103107

@@ -122,14 +126,16 @@ clean$(1)_T_$(2)_H_$(3):
122126
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(2))
123127
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(2))
124128
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(STDLIB_GLOB_$(2))
129+
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(STDLIB_RGLOB_$(2))
125130
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(EXTRALIB_GLOB_$(2))
131+
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(EXTRALIB_RGLOB_$(2))
126132
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBRUSTUV_GLOB_$(2))
133+
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBRUSTUV_RGLOB_$(2))
127134
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBRUSTC_GLOB_$(2))
128135
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBSYNTAX_GLOB_$(2))
129136
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBRUSTPKG_GLOB_$(2))
130137
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(LIBRUSTDOC_GLOB_$(2))
131138
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_RUSTLLVM_$(2))
132-
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/libstd.rlib
133139
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/libmorestack.a
134140
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/librun_pass_stage* # For unix
135141
$(Q)rm -f $$(TLIB$(1)_T_$(2)_H_$(3))/run_pass_stage* # For windows

mk/host.mk

+10-25
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ $$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTC_$(4)): \
5050
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(4)),$$(notdir $$@))
5151
$$(Q)cp $$< $$@
5252
$$(Q)cp -R $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTC_GLOB_$(4)) \
53-
$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTC_DSYM_GLOB_$(4))) \
53+
$$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTC_DSYM_GLOB_$(4))) \
5454
$$(HLIB$(2)_H_$(4))
5555
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(4)),$$(notdir $$@))
5656

@@ -82,6 +82,7 @@ $$(HLIB$(2)_H_$(4))/$(CFG_STDLIB_$(4)): \
8282
| $$(HLIB$(2)_H_$(4))/
8383
@$$(call E, cp: $$@)
8484
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(4)),$$(notdir $$@))
85+
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(4)),$$(notdir $$@))
8586
$$(Q)cp $$< $$@
8687
# Subtle: We do not let the shell expand $$(STDLIB_DSYM_GLOB) directly rather
8788
# we use Make's $$(wildcard) facility. The reason is that, on mac, when using
@@ -91,9 +92,11 @@ $$(HLIB$(2)_H_$(4))/$(CFG_STDLIB_$(4)): \
9192
# Make instead expands the glob to nothing, which gives us the correct behavior.
9293
# (Copy .dsym file if it exists, but do nothing otherwise)
9394
$$(Q)cp -R $$(TLIB$(1)_T_$(4)_H_$(3))/$(STDLIB_GLOB_$(4)) \
95+
$$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(STDLIB_RGLOB_$(4))) \
9496
$$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(STDLIB_DSYM_GLOB_$(4))) \
9597
$$(HLIB$(2)_H_$(4))
9698
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(4)),$$(notdir $$@))
99+
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(4)),$$(notdir $$@))
97100

98101
$$(HLIB$(2)_H_$(4))/$(CFG_EXTRALIB_$(4)): \
99102
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_EXTRALIB_$(4)) \
@@ -102,11 +105,14 @@ $$(HLIB$(2)_H_$(4))/$(CFG_EXTRALIB_$(4)): \
102105
| $$(HLIB$(2)_H_$(4))/
103106
@$$(call E, cp: $$@)
104107
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(4)),$$(notdir $$@))
108+
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(4)),$$(notdir $$@))
105109
$$(Q)cp $$< $$@
106110
$$(Q)cp -R $$(TLIB$(1)_T_$(4)_H_$(3))/$(EXTRALIB_GLOB_$(4)) \
111+
$$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(EXTRALIB_RGLOB_$(4))) \
107112
$$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(EXTRALIB_DSYM_GLOB_$(4))) \
108113
$$(HLIB$(2)_H_$(4))
109114
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(4)),$$(notdir $$@))
115+
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(4)),$$(notdir $$@))
110116

111117
$$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTUV_$(4)): \
112118
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTUV_$(4)) \
@@ -115,35 +121,14 @@ $$(HLIB$(2)_H_$(4))/$(CFG_LIBRUSTUV_$(4)): \
115121
| $$(HLIB$(2)_H_$(4))/
116122
@$$(call E, cp: $$@)
117123
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(4)),$$(notdir $$@))
124+
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(4)),$$(notdir $$@))
118125
$$(Q)cp $$< $$@
119126
$$(Q)cp -R $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTUV_GLOB_$(4)) \
127+
$$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTUV_RGLOB_$(4))) \
120128
$$(wildcard $$(TLIB$(1)_T_$(4)_H_$(3))/$(LIBRUSTUV_DSYM_GLOB_$(4))) \
121129
$$(HLIB$(2)_H_$(4))
122130
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(4)),$$(notdir $$@))
123-
124-
$$(HLIB$(2)_H_$(4))/libstd.rlib: \
125-
$$(TLIB$(1)_T_$(4)_H_$(3))/libstd.rlib \
126-
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4)) \
127-
| $$(HLIB$(2)_H_$(4))/
128-
@$$(call E, cp: $$@)
129-
$$(Q)cp $$< $$@
130-
131-
$$(HLIB$(2)_H_$(4))/libextra.rlib: \
132-
$$(TLIB$(1)_T_$(4)_H_$(3))/libextra.rlib \
133-
$$(HLIB$(2)_H_$(4))/libstd.rlib \
134-
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4)) \
135-
| $$(HLIB$(2)_H_$(4))/
136-
@$$(call E, cp: $$@)
137-
$$(Q)cp $$< $$@
138-
139-
$$(HLIB$(2)_H_$(4))/librustc.rlib: \
140-
$$(TLIB$(1)_T_$(4)_H_$(3))/librustc.rlib \
141-
$$(HLIB$(2)_H_$(4))/libstd.rlib \
142-
$$(HLIB$(2)_H_$(4))/libextra.rlib \
143-
$$(HLIB$(2)_H_$(4))/$$(CFG_RUNTIME_$(4)) \
144-
| $$(HLIB$(2)_H_$(4))/
145-
@$$(call E, cp: $$@)
146-
$$(Q)cp $$< $$@
131+
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(4)),$$(notdir $$@))
147132

148133
$$(HLIB$(2)_H_$(4))/$(CFG_RUSTLLVM_$(4)): \
149134
$$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_RUSTLLVM_$(4)) \

mk/install.mk

+6
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,11 @@ install-host: $(CSREQ$(ISTAGE)_T_$(CFG_BUILD_)_H_$(CFG_BUILD_))
144144
$(Q)$(call INSTALL,$(HB2),$(PHB),rustpkg$(X_$(CFG_BUILD)))
145145
$(Q)$(call INSTALL,$(HB2),$(PHB),rustdoc$(X_$(CFG_BUILD)))
146146
$(Q)$(call INSTALL_LIB,$(STDLIB_GLOB_$(CFG_BUILD)))
147+
$(Q)$(call INSTALL_LIB,$(STDLIB_RGLOB_$(CFG_BUILD)))
147148
$(Q)$(call INSTALL_LIB,$(EXTRALIB_GLOB_$(CFG_BUILD)))
149+
$(Q)$(call INSTALL_LIB,$(EXTRALIB_RGLOB_$(CFG_BUILD)))
148150
$(Q)$(call INSTALL_LIB,$(LIBRUSTUV_GLOB_$(CFG_BUILD)))
151+
$(Q)$(call INSTALL_LIB,$(LIBRUSTUV_RGLOB_$(CFG_BUILD)))
149152
$(Q)$(call INSTALL_LIB,$(LIBRUSTC_GLOB_$(CFG_BUILD)))
150153
$(Q)$(call INSTALL_LIB,$(LIBSYNTAX_GLOB_$(CFG_BUILD)))
151154
$(Q)$(call INSTALL_LIB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD)))
@@ -170,8 +173,11 @@ uninstall:
170173
$(Q)rm -f $(PHL)/$(CFG_RUNTIME_$(CFG_BUILD))
171174
$(Q)for i in \
172175
$(call HOST_LIB_FROM_HL_GLOB,$(STDLIB_GLOB_$(CFG_BUILD))) \
176+
$(call HOST_LIB_FROM_HL_GLOB,$(STDLIB_RGLOB_$(CFG_BUILD))) \
173177
$(call HOST_LIB_FROM_HL_GLOB,$(EXTRALIB_GLOB_$(CFG_BUILD))) \
178+
$(call HOST_LIB_FROM_HL_GLOB,$(EXTRALIB_RGLOB_$(CFG_BUILD))) \
174179
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTUV_GLOB_$(CFG_BUILD))) \
180+
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTUV_RGLOB_$(CFG_BUILD))) \
175181
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTC_GLOB_$(CFG_BUILD))) \
176182
$(call HOST_LIB_FROM_HL_GLOB,$(LIBSYNTAX_GLOB_$(CFG_BUILD))) \
177183
$(call HOST_LIB_FROM_HL_GLOB,$(LIBRUSTPKG_GLOB_$(CFG_BUILD))) \

mk/platform.mk

+1
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ endif
138138
endif
139139
endif
140140

141+
CFG_RLIB_GLOB=lib$(1)-*.rlib
141142

142143
# x86_64-unknown-linux-gnu configuration
143144
CC_x86_64-unknown-linux-gnu=$(CC)

mk/target.mk

+6
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,10 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
6060
| $$(TLIB$(1)_T_$(2)_H_$(3))/
6161
@$$(call E, compile_and_link: $$@)
6262
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
63+
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
6364
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
6465
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
66+
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_RGLOB_$(2)),$$(notdir $$@))
6567

6668
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
6769
$$(EXTRALIB_CRATE) $$(EXTRALIB_INPUTS) \
@@ -70,8 +72,10 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
7072
| $$(TLIB$(1)_T_$(2)_H_$(3))/
7173
@$$(call E, compile_and_link: $$@)
7274
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
75+
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
7376
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
7477
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
78+
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_RGLOB_$(2)),$$(notdir $$@))
7579

7680
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2)): \
7781
$$(LIBRUSTUV_CRATE) $$(LIBRUSTUV_INPUTS) \
@@ -82,11 +86,13 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTUV_$(2)): \
8286
| $$(TLIB$(1)_T_$(2)_H_$(3))/
8387
@$$(call E, compile_and_link: $$@)
8488
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
89+
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(2)),$$(notdir $$@))
8590
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) \
8691
-L $$(UV_SUPPORT_DIR_$(2)) \
8792
-L $$(dir $$(LIBUV_LIB_$(2))) \
8893
--out-dir $$(@D) $$< && touch $$@
8994
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_GLOB_$(2)),$$(notdir $$@))
95+
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTUV_RGLOB_$(2)),$$(notdir $$@))
9096

9197
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
9298
$$(LIBSYNTAX_CRATE) $$(LIBSYNTAX_INPUTS) \

mk/tests.mk

+4
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,10 @@ TEST_SREQ$(1)_T_$(2)_H_$(3) = \
584584
# remove directive, if present, from CFG_RUSTC_FLAGS (issue #7898).
585585
CTEST_RUSTC_FLAGS := $$(subst --cfg ndebug,,$$(CFG_RUSTC_FLAGS))
586586

587+
# There's no need our entire test suite to take up gigabytes of space on disk
588+
# including copies of libstd/libextra all over the place
589+
CTEST_RUSTC_FLAGS := $$(CTEST_RUSTC_FLAGS) -Z prefer-dynamic
590+
587591
# The tests can not be optimized while the rest of the compiler is optimized, so
588592
# filter out the optimization (if any) from rustc and then figure out if we need
589593
# to be optimized

src/libextra/flate.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ use std::vec;
2323
pub mod rustrt {
2424
use std::libc::{c_int, c_void, size_t};
2525

26-
#[link_name = "rustrt"]
26+
#[link(name = "rustrt")]
2727
extern {
2828
pub fn tdefl_compress_mem_to_heap(psrc_buf: *c_void,
2929
src_buf_len: size_t,

src/libextra/lib.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ Rust extras are part of the standard Rust distribution.
3232

3333
#[comment = "Rust extras"];
3434
#[license = "MIT/ASL2"];
35-
#[crate_type = "lib"];
35+
#[crate_type = "lib"]; // NOTE: remove after stage0 snapshot
36+
#[crate_type = "rlib"];
37+
#[crate_type = "dylib"];
3638

3739
#[feature(macro_rules, globs, managed_boxes)];
3840

0 commit comments

Comments
 (0)