Skip to content

Commit 4bd302e

Browse files
committed
Auto merge of #29794 - semarie:openbsd-stdcpp-path, r=alexcrichton
under openbsd, the library path of libstdc++ need to be explicit (due to the fact the default linker `cc` is gcc-4.2, and not gcc-4.9). but when a recent LLVM is installed, rustc compilation pikes the bad LLVM version (which live in /usr/local/lib, which is same directory of libestdc++.so for gcc-4.9). this patch move the libstdc++ path from RUST_FLAGS_<target> to special variable, and use it *after* LLVM_LIBDIR_RUSTFLAGS_<target> in arguments. r? @alexcrichton
2 parents a7644b3 + 646b0b6 commit 4bd302e

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

mk/platform.mk

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,11 @@ define CFG_MAKE_TOOLCHAIN
214214
# On OpenBSD, we need to pass the path of libstdc++.so to the linker
215215
# (use path of libstdc++.a which is a known name for the same path)
216216
ifeq ($(OSTYPE_$(1)),unknown-openbsd)
217-
RUSTC_FLAGS_$(1)=-L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
218-
-print-file-name=lib$(CFG_STDCPP_NAME).a))" \
219-
$(RUSTC_FLAGS_$(1))
217+
STDCPP_LIBDIR_RUSTFLAGS_$(1)= \
218+
-L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
219+
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
220+
else
221+
STDCPP_LIBDIR_RUSTFLAGS_$(1)=
220222
endif
221223

222224
# On Bitrig, we need the relocation model to be PIC for everything

mk/target.mk

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
9595
$$(RUSTFLAGS_$(4)) \
9696
$$(RUSTFLAGS$(1)_$(4)) \
9797
$$(RUSTFLAGS$(1)_$(4)_T_$(2)) \
98+
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2)) \
9899
--out-dir $$(@D) \
99100
-C extra-filename=-$$(CFG_FILENAME_EXTRA) \
100101
$$<
@@ -128,7 +129,9 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
128129
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
129130
| $$(TBIN$(1)_T_$(2)_H_$(3))/
130131
@$$(call E, rustc: $$@)
131-
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg $(4)
132+
$$(STAGE$(1)_T_$(2)_H_$(3)) \
133+
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2)) \
134+
-o $$@ $$< --cfg $(4)
132135

133136
endef
134137

mk/tests.mk

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,8 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
393393
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
394394
-L "$$(RT_OUTPUT_DIR_$(2))" \
395395
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
396-
$$(RUSTFLAGS_$(4))
396+
$$(RUSTFLAGS_$(4)) \
397+
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2))
397398

398399
endef
399400

@@ -663,9 +664,9 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
663664
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
664665
--adb-path=$(CFG_ADB) \
665666
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
666-
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
667+
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3)) $$(STDCPP_LIBDIR_RUSTFLAGS_$(3))" \
667668
--lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
668-
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
669+
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2)) $$(STDCPP_LIBDIR_RUSTFLAGS_$(2))" \
669670
$$(CTEST_TESTARGS)
670671

671672
ifdef CFG_VALGRIND_RPASS

0 commit comments

Comments
 (0)