Skip to content

Commit fd01031

Browse files
committed
Warn when using -o option on libraries. Closes #6554.
1 parent a200816 commit fd01031

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

mk/target.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_STDLIB_$(2)): \
4848
| $$(TLIB$(1)_T_$(2)_H_$(3))/
4949
@$$(call E, compile_and_link: $$@)
5050
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
51-
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) -o $$@ $$< && touch $$@
51+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
5252
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(STDLIB_GLOB_$(2)),$$(notdir $$@))
5353

5454
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
@@ -58,7 +58,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_EXTRALIB_$(2)): \
5858
| $$(TLIB$(1)_T_$(2)_H_$(3))/
5959
@$$(call E, compile_and_link: $$@)
6060
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
61-
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) -o $$@ $$< && touch $$@
61+
$$(STAGE$(1)_T_$(2)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
6262
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(EXTRALIB_GLOB_$(2)),$$(notdir $$@))
6363

6464
$$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
@@ -69,7 +69,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBSYNTAX_$(3)): \
6969
| $$(TLIB$(1)_T_$(2)_H_$(3))/
7070
@$$(call E, compile_and_link: $$@)
7171
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
72-
$$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) -o $$@ $$< && touch $$@
72+
$$(STAGE$(1)_T_$(2)_H_$(3)) $(BORROWCK) --out-dir $$(@D) $$< && touch $$@
7373
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBSYNTAX_GLOB_$(2)),$$(notdir $$@))
7474

7575
# Only build the compiler for host triples
@@ -90,7 +90,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/$(CFG_LIBRUSTC_$(3)): \
9090
| $$(TLIB$(1)_T_$(2)_H_$(3))/
9191
@$$(call E, compile_and_link: $$@)
9292
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
93-
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< && touch $$@
93+
$$(STAGE$(1)_T_$(2)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
9494
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTC_GLOB_$(2)),$$(notdir $$@))
9595

9696
$$(TBIN$(1)_T_$(2)_H_$(3))/rustc$$(X_$(3)): \

mk/tools.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTPKG_$(4)): \
4949
| $$(TLIB$(1)_T_$(4)_H_$(3))/
5050
@$$(call E, compile_and_link: $$@)
5151
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTPKG_GLOB_$(4)),$$(notdir $$@))
52-
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) -o $$@ $$< && touch $$@
52+
$$(STAGE$(1)_T_$(4)_H_$(3)) $$(WFLAGS_ST$(1)) --out-dir $$(@D) $$< && touch $$@
5353
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTPKG_GLOB_$(4)),$$(notdir $$@))
5454

5555
$$(TBIN$(1)_T_$(4)_H_$(3))/rustpkg$$(X_$(4)): \
@@ -67,7 +67,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTDOC_$(4)): \
6767
| $$(TLIB$(1)_T_$(4)_H_$(3))/
6868
@$$(call E, compile_and_link: $$@)
6969
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTDOC_GLOB_$(4)),$$(notdir $$@))
70-
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
70+
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
7171
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTDOC_GLOB_$(4)),$$(notdir $$@))
7272

7373
$$(TBIN$(1)_T_$(4)_H_$(3))/rustdoc$$(X_$(4)): \
@@ -85,7 +85,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUSTI_$(4)): \
8585
| $$(TLIB$(1)_T_$(4)_H_$(3))/
8686
@$$(call E, compile_and_link: $$@)
8787
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTI_GLOB_$(4)),$$(notdir $$@))
88-
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
88+
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
8989
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUSTI_GLOB_$(4)),$$(notdir $$@))
9090

9191
$$(TBIN$(1)_T_$(4)_H_$(3))/rusti$$(X_$(4)): \
@@ -106,7 +106,7 @@ $$(TLIB$(1)_T_$(4)_H_$(3))/$(CFG_LIBRUST_$(4)): \
106106
| $$(TLIB$(1)_T_$(4)_H_$(3))/
107107
@$$(call E, compile_and_link: $$@)
108108
$$(call REMOVE_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUST_GLOB_$(4)),$$(notdir $$@))
109-
$$(STAGE$(1)_T_$(4)_H_$(3)) -o $$@ $$< && touch $$@
109+
$$(STAGE$(1)_T_$(4)_H_$(3)) --out-dir $$(@D) $$< && touch $$@
110110
$$(call LIST_ALL_OLD_GLOB_MATCHES_EXCEPT,$$(dir $$@),$(LIBRUST_GLOB_$(4)),$$(notdir $$@))
111111

112112
$$(TBIN$(1)_T_$(4)_H_$(3))/rust$$(X_$(4)): \

src/librustc/driver/driver.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -408,19 +408,21 @@ pub fn stop_after_phase_5(sess: Session) -> bool {
408408
#[fixed_stack_segment]
409409
pub fn compile_input(sess: Session, cfg: ast::CrateConfig, input: &input,
410410
outdir: &Option<Path>, output: &Option<Path>) {
411-
let outputs = build_output_filenames(input, outdir, output, [], sess);
412411
// We need nested scopes here, because the intermediate results can keep
413412
// large chunks of memory alive and we want to free them as soon as
414413
// possible to keep the peak memory usage low
415-
let trans = {
414+
let (outputs, trans) = {
416415
let expanded_crate = {
417416
let crate = phase_1_parse_input(sess, cfg.clone(), input);
418417
if stop_after_phase_1(sess) { return; }
419418
phase_2_configure_and_expand(sess, cfg, crate)
420419
};
421420
let analysis = phase_3_run_analysis_passes(sess, expanded_crate);
422421
if stop_after_phase_3(sess) { return; }
423-
phase_4_translate_to_llvm(sess, expanded_crate, &analysis, outputs)
422+
let outputs = build_output_filenames(input, outdir, output, [], sess);
423+
let trans = phase_4_translate_to_llvm(sess, expanded_crate,
424+
&analysis, outputs);
425+
(outputs, trans)
424426
};
425427
phase_5_run_llvm_passes(sess, &trans, outputs);
426428
if stop_after_phase_5(sess) { return; }
@@ -957,10 +959,7 @@ pub fn build_output_filenames(input: &input,
957959
};
958960

959961
if *sess.building_library {
960-
// FIXME (#2401): We might want to warn here; we're actually not
961-
// going to respect the user's choice of library name when it
962-
// comes time to link, we'll be linking to
963-
// lib<basename>-<hash>-<version>.so no matter what.
962+
sess.warn("ignoring specified output filename for library.");
964963
}
965964

966965
if *odir != None {

0 commit comments

Comments
 (0)