Skip to content

Commit 29e60ab

Browse files
committed
Auto merge of #30493 - semarie:openbsd-cc, r=alexcrichton
this PR reverts previous ones, that tried to make `cc` to found `estdc++` in `/usr/local/lib`. It causes more trouble than it resolvs things: rustc become unbuildable if another version already exists in `/usr/local` (for example, `libstd-xxxx.so` is found in `/usr/local/lib` and in builddir). so this PR tries another way to achieve build, but using the good linker for building. By default, rustc use `cc` for linking. But under OpenBSD, `cc` is gcc 4.2.1 from base, whereas we build with gcc 4.9 from ports. By linking using the compiler found at compile-time, we ensure that the compiler will found his own stdc++ library without trouble. r? @alexcrichton
2 parents c6079d0 + b74359a commit 29e60ab

File tree

5 files changed

+5
-21
lines changed

5 files changed

+5
-21
lines changed

mk/cfg/x86_64-unknown-openbsd.mk

+1
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,4 @@ CFG_LDPATH_x86_64-unknown-openbsd :=
2020
CFG_RUN_x86_64-unknown-openbsd=$(2)
2121
CFG_RUN_TARG_x86_64-unknown-openbsd=$(call CFG_RUN_x86_64-unknown-openbsd,,$(2))
2222
CFG_GNU_TRIPLE_x86_64-unknown-openbsd := x86_64-unknown-openbsd
23+
RUSTC_FLAGS_x86_64-unknown-openbsd=-C linker=$(call FIND_COMPILER,$(CC))

mk/platform.mk

-10
Original file line numberDiff line numberDiff line change
@@ -215,16 +215,6 @@ define CFG_MAKE_TOOLCHAIN
215215

216216
ifeq ($$(findstring $(HOST_$(1)),arm aarch64 mips mipsel powerpc),)
217217

218-
# On OpenBSD, we need to pass the path of libstdc++.so to the linker
219-
# (use path of libstdc++.a which is a known name for the same path)
220-
ifeq ($(OSTYPE_$(1)),unknown-openbsd)
221-
STDCPP_LIBDIR_RUSTFLAGS_$(1)= \
222-
-L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
223-
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
224-
else
225-
STDCPP_LIBDIR_RUSTFLAGS_$(1)=
226-
endif
227-
228218
# On Bitrig, we need the relocation model to be PIC for everything
229219
ifeq (,$(filter $(OSTYPE_$(1)),bitrig))
230220
LLVM_MC_RELOCATION_MODEL="pic"

mk/target.mk

-2
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,6 @@ $$(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)) \
9998
--out-dir $$(@D) \
10099
-C extra-filename=-$$(CFG_FILENAME_EXTRA) \
101100
$$<
@@ -130,7 +129,6 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
130129
| $$(TBIN$(1)_T_$(2)_H_$(3))/
131130
@$$(call E, rustc: $$@)
132131
$$(STAGE$(1)_T_$(2)_H_$(3)) \
133-
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2)) \
134132
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
135133
-o $$@ $$< --cfg $(4)
136134

mk/tests.mk

+3-4
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,7 @@ $(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)) \
397-
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2))
396+
$$(RUSTFLAGS_$(4))
398397

399398
endef
400399

@@ -664,9 +663,9 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
664663
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
665664
--adb-path=$(CFG_ADB) \
666665
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
667-
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3)) $$(STDCPP_LIBDIR_RUSTFLAGS_$(3))" \
666+
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
668667
--lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
669-
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2)) $$(STDCPP_LIBDIR_RUSTFLAGS_$(2))" \
668+
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
670669
$$(CTEST_TESTARGS)
671670

672671
ifdef CFG_VALGRIND_RPASS

src/test/run-make/tools.mk

+1-5
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,7 @@ ifeq ($(UNAME),Bitrig)
8585
else
8686
ifeq ($(UNAME),OpenBSD)
8787
EXTRACFLAGS := -lm -lpthread
88-
# extend search lib for found estdc++ if build using gcc from
89-
# ports under OpenBSD. This is needed for:
90-
# - run-make/execution-engine
91-
# - run-make/issue-19371
92-
RUSTC := $(RUSTC) -L/usr/local/lib
88+
RUSTC := $(RUSTC) -C linker="$(word 1,$(CC:ccache=))"
9389
else
9490
EXTRACFLAGS := -lm -lrt -ldl -lpthread
9591
EXTRACXXFLAGS := -lstdc++

0 commit comments

Comments
 (0)