Skip to content
This repository was archived by the owner on Oct 12, 2022. It is now read-only.
/ druntime Public archive

Conversation

@jmdavis
Copy link
Member

@jmdavis jmdavis commented Dec 23, 2016

This fixes it so that the builds in the test folder are built with
-fPIC when the unittest build is run with PIC=1. Unfortunately, the
line_trace test in test/exceptions is then failing (at least on my
system), because it doesn't actually generate a stacktrace. So, this
doesn't seem to completely fix it so that the PIC=1 unittest build
works, but it's close.

GENERATED:=./generated
ROOT:=$(GENERATED)/$(OS)/$(BUILD)/$(MODEL)

OPTIONAL_PIC:=$(if $(PIC),-fPIC,)
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to explicitly pass OPTIONAL_PIC=$(OPTIONAL_PIC) from the top makefile as is done for the other variables above.
See

druntime/posix.mak

Lines 264 to 266 in 4af3423

$(QUIET)$(MAKE) -C test/$* MODEL=$(MODEL) OS=$(OS) DMD=$(abspath $(DMD)) BUILD=$(BUILD) \
DRUNTIME=$(abspath $(DRUNTIME)) DRUNTIMESO=$(abspath $(DRUNTIMESO)) LINKDL=$(LINKDL) \
QUIET=$(QUIET) TIMELIMIT='$(TIMELIMIT)'
.
The fact that explict CLI arguments (like PIC=1) are passed to proper submake invocations is fairly subtle to rely on.

Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Member Author

Choose a reason for hiding this comment

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

Okay. I just added it as an argument.

Copy link
Contributor

@Burgos Burgos Jul 9, 2017

Choose a reason for hiding this comment

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

@jmdavis why not pass OPTIONAL_PIC (as @MartinNowak suggested), instead of PIC, so the OPTIONAL_PIC doesn't need to be calculated again?

Copy link
Member Author

Choose a reason for hiding this comment

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

I thought that I had done what was requested, but I could have misunderstood, and my makefile-foo is quite weak.

@jmdavis
Copy link
Member Author

jmdavis commented May 5, 2017

Rebased.

@Burgos
Copy link
Contributor

Burgos commented Jul 9, 2017

With my comment applied, or as is, I think we should merge this. I've installed Arch today and spent an hour trying to figure out why druntime unittests are failing - it lead to #1863, but I'll close it now as a duplicate of this. cc @MartinNowak @andralex

IMHO, it's a simple bugfix and it's staled from December.

@nemanja-boric-sociomantic
Copy link
Contributor

Also needs rebase now :(

This fixes it so that the builds in the test folder are built with
-fPIC when the unittest build is run with PIC=1. Unfortunately, the
line_trace test in test/exceptions is then failing (at least on my
system), because it doesn't actually generate a stacktrace. So, this
doesn't seem to completely fix it so that the PIC=1 unittest build
works, but it's close.
@dlang-bot
Copy link
Contributor

Thanks for your pull request, @jmdavis!

Bugzilla references

Your PR doesn't reference any Bugzilla issue.

If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog.

@wilzbach
Copy link
Contributor

Also needs rebase now :(

Rebased.

@wilzbach
Copy link
Contributor

Btw as -fPIC is the default for dmd on Posix since 2.072, why don't we enable -fPIC for druntime as default as well? More an more OSes are moving towards this hardening anyways.
FYI: I also proposed to do this for Phobos: dlang/phobos#5586

@dlang-bot dlang-bot merged commit f9276a7 into dlang:master Jul 10, 2017
@wilzbach wilzbach mentioned this pull request Jul 18, 2017
2 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants