Skip to content

Commit 646b0b6

Browse files
committed
pass stdc++ library path after LVVM library path
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.
1 parent 05b66b8 commit 646b0b6

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
@@ -392,7 +392,8 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
392392
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
393393
-L "$$(RT_OUTPUT_DIR_$(2))" \
394394
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
395-
$$(RUSTFLAGS_$(4))
395+
$$(RUSTFLAGS_$(4)) \
396+
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2))
396397

397398
endef
398399

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

670671
ifdef CFG_VALGRIND_RPASS

0 commit comments

Comments
 (0)