Skip to content
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

Fix issue 19116 - Segfaults on recent Linux 32 bits distros #9981

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SSoulaimane
Copy link
Member

Pass the -no-pie flag to cc on Linux 32 bits.

Re-enables CircleCi 32 bits tests which were previously disabled in #9499.

@WalterBright
Copy link
Member

I think it would be much better to find out what the PIE code gen issue is.

@WalterBright
Copy link
Member

@SSoulaimane
Copy link
Member Author

@WalterBright There is no codegen issue. LDC turned on PIC by default ldc-developers/ldc#1618 & ldc-developers/ldc#1664

@SSoulaimane
Copy link
Member Author

SSoulaimane commented Nov 3, 2019

The rust compiler runs the linker with -no-pie if it fails it removes it. rust-lang/rust@f0e9af1.

@wilzbach
Copy link
Member

wilzbach commented Nov 3, 2019

@SSoulaimane uhm thanks a lot for this work, but I'm not sure this is a good investment of your time. As this has been broken for years, it clearly shows that either no one uses DMD 32-bit anymore on Linux or they switched to LDC. In either case, the 32-bit -no-pie test is already done by the auto-tester, so there's no real gain of this (except for adding more load to the circleci build queue).

@SSoulaimane
Copy link
Member Author

SSoulaimane commented Nov 3, 2019

@wilzbach Thanks. It's not a hard problem though. We just need to make a decision, we either turn PIC on, or read the linker output.

@PetarKirov
Copy link
Member

@SSoulaimane I suggest to turn PIC on by default and provide the option to disable it for the rare cases where this may be necessary.

@SSoulaimane SSoulaimane force-pushed the fix19116 branch 6 times, most recently from 9674369 to b0dc2c7 Compare November 18, 2019 22:36
@SSoulaimane
Copy link
Member Author

@PetarKirov I thought about it but then if we had a working option that turns PIC off we could just use it and keep PIC off by default.
I found out that there is an easy reliable way to probe the compiler and see whether it has this default PIE or not. Just run cc -v and see if --enable-default-pie is in the output.

@SSoulaimane
Copy link
Member Author

@wilzbach I thought only 32bits had problems but turning on CircleCi no_pic tests revealed that x86_64 tests fail when linking phobos (see link) but the -no-pie flag fixes it. Is no_pic no longer supported on x86_64?

@wilzbach
Copy link
Member

Is no_pic no longer supported on x86_64?

Uhm I'm not sure how I am supposed to know this, though most/all? major Linux distributions have switched to PIC only quite a while ago, so I wouldn't be surprised if non-PIC is no longer tested nor supported unofficially. There would be little point in fixing it in this case.

@SSoulaimane SSoulaimane marked this pull request as ready for review November 19, 2019 13:13
@SSoulaimane
Copy link
Member Author

@wilzbach It's fixed now I don't know if you want to keep the circle ci tests or not.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @SSoulaimane! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
19116 normal dmd compiles binary but segfaults immediately when run on Ubuntu / Debian 32Bit architectures

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub fetch digger
dub run digger -- build "master + dmd#9981"

FILE* fp = popen(cmd.peekChars(), "r");
scope(exit) pclose(fp);
return 1 == findStr(fp, "--enable-default-pie");
}
Copy link
Member

Choose a reason for hiding this comment

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

What's the overhead in opening this process on every compilation? 🤔

Copy link
Member Author

@SSoulaimane SSoulaimane Nov 19, 2019

Choose a reason for hiding this comment

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

The linker is slow anyway would be an argument.
But maybe we can pessimize older cc versions instead of the new ones i.e optimistically assume that cc can handle the -no-pie switch and retry if it fails.

Check the linker (cc) on linux if it assumes PIE by default to turn it off when linking non-PIC code.

We check the linker build flags since this option only applies to GCC 6 and newer.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants