Skip to content

openbsd: pass stdc++ library path after LVVM library path #29794

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 17, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions mk/platform.mk
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,11 @@ define CFG_MAKE_TOOLCHAIN
# On OpenBSD, we need to pass the path of libstdc++.so to the linker
# (use path of libstdc++.a which is a known name for the same path)
ifeq ($(OSTYPE_$(1)),unknown-openbsd)
RUSTC_FLAGS_$(1)=-L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
-print-file-name=lib$(CFG_STDCPP_NAME).a))" \
$(RUSTC_FLAGS_$(1))
STDCPP_LIBDIR_RUSTFLAGS_$(1)= \
-L "$$(dir $$(shell $$(CC_$(1)) $$(CFG_GCCISH_CFLAGS_$(1)) \
-print-file-name=lib$(CFG_STDCPP_NAME).a))"
else
STDCPP_LIBDIR_RUSTFLAGS_$(1)=
endif

# On Bitrig, we need the relocation model to be PIC for everything
Expand Down
5 changes: 4 additions & 1 deletion mk/target.mk
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ $$(TLIB$(1)_T_$(2)_H_$(3))/stamp.$(4): \
$$(RUSTFLAGS_$(4)) \
$$(RUSTFLAGS$(1)_$(4)) \
$$(RUSTFLAGS$(1)_$(4)_T_$(2)) \
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2)) \
--out-dir $$(@D) \
-C extra-filename=-$$(CFG_FILENAME_EXTRA) \
$$<
Expand Down Expand Up @@ -128,7 +129,9 @@ $$(TBIN$(1)_T_$(2)_H_$(3))/$(4)$$(X_$(2)): \
$$(TSREQ$(1)_T_$(2)_H_$(3)) \
| $$(TBIN$(1)_T_$(2)_H_$(3))/
@$$(call E, rustc: $$@)
$$(STAGE$(1)_T_$(2)_H_$(3)) -o $$@ $$< --cfg $(4)
$$(STAGE$(1)_T_$(2)_H_$(3)) \
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2)) \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was this necessary to compile correctly? No other extra flags are passed in here so I'm a little wary this should be needed for correctness.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. In this target, we do the final linking of a tool binary. So the path for libstdc++ has to be know.

Before, the value came from RUST_FLAGS_<target>. Now we need to explicitly add it.

The error without it is:

note: /usr/bin/ld: cannot find -lestdc++
collect2: ld returned 1 exit status

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hm right, I guess maybe this'll all be nice to look at one day...

-o $$@ $$< --cfg $(4)

endef

Expand Down
7 changes: 4 additions & 3 deletions mk/tests.mk
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,8 @@ $(3)/stage$(1)/test/$(4)test-$(2)$$(X_$(2)): \
$$(subst @,,$$(STAGE$(1)_T_$(2)_H_$(3))) -o $$@ $$< --test \
-L "$$(RT_OUTPUT_DIR_$(2))" \
$$(LLVM_LIBDIR_RUSTFLAGS_$(2)) \
$$(RUSTFLAGS_$(4))
$$(RUSTFLAGS_$(4)) \
$$(STDCPP_LIBDIR_RUSTFLAGS_$(2))

endef

Expand Down Expand Up @@ -662,9 +663,9 @@ CTEST_COMMON_ARGS$(1)-T-$(2)-H-$(3) := \
--android-cross-path=$(CFG_ANDROID_CROSS_PATH) \
--adb-path=$(CFG_ADB) \
--adb-test-dir=$(CFG_ADB_TEST_DIR) \
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3))" \
--host-rustcflags "$(RUSTC_FLAGS_$(3)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(3)) $$(STDCPP_LIBDIR_RUSTFLAGS_$(3))" \
--lldb-python-dir=$(CFG_LLDB_PYTHON_DIR) \
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2))" \
--target-rustcflags "$(RUSTC_FLAGS_$(2)) $$(CTEST_RUSTC_FLAGS) -L $$(RT_OUTPUT_DIR_$(2)) $$(STDCPP_LIBDIR_RUSTFLAGS_$(2))" \
$$(CTEST_TESTARGS)

ifdef CFG_VALGRIND_RPASS
Expand Down