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

[ltsmaster] Emit constructors as .init_array instead of .ctors when appropriate #2883

Merged
merged 1 commit into from
Nov 3, 2018

Conversation

valpackett
Copy link
Contributor

@valpackett valpackett commented Oct 25, 2018

AArch64 only supports .init_array, for example. The reason this wasn't discovered earlier is that BFD and gold linkers automatically convert .ctors to .init_array as a performance optimization.

Based on clang code: https://github.com/llvm-mirror/clang/blob/5897428cd24e2deefbcc6f6744c0d7d233aa6747/lib/Driver/ToolChains/Gnu.cpp#L2598-L2620

ldc-developers/druntime#146

@kinke
Copy link
Member

kinke commented Oct 26, 2018

Thx; too bad that ugly piece of code isn't in LLVM itself; it apparently defaults to .init_array on Linux.

@valpackett
Copy link
Contributor Author

it apparently defaults to .init_array on Linux

LLVM itself? hm, why does clang then have a check for the GCC installation on Linux:

(getTriple().getOS() == llvm::Triple::Linux &&
       ((!GCCInstallation.isValid() || !V.isOlderThan(4, 7, 0)) ||
getTriple().isAndroid()))

@kinke
Copy link
Member

kinke commented Oct 26, 2018

LLVM itself?

Yep, as can be seen by compiling with -output-s -mtriple={x86_64,aarch64}-linux-gnu; the object file sections are .{init,fini}_array, i.e., not converted by the linker.

why does clang then

Don't know, don't care. ;)

@JohanEngelen
Copy link
Member

This looks OK to me, besides a missing test case. No need to test all the different possible triples, but a test with one triple and checking that setting that targetOption flag actually does the right thing would be good.
Any other concerns @kinke ?

@kinke
Copy link
Member

kinke commented Oct 31, 2018

Nope, no concerns from my side. We must not forget to cherry-pick it to master afterwards.

@JohanEngelen
Copy link
Member

@myfreeweb Can you fix the build errors in the CI? (just use #ifdef to remove the checking of triples unknown to older LLVMs)

AArch64 only supports .init_array, for example. The reason this wasn't discovered
earlier is that BFD and gold linkers automatically convert .ctors to .init_array
as a performance optimization.
@valpackett
Copy link
Contributor Author

Now passes on travis. Semaphore seems dead

@JohanEngelen JohanEngelen merged commit ada499c into ldc-developers:ltsmaster Nov 3, 2018
JohanEngelen pushed a commit to JohanEngelen/ldc that referenced this pull request Nov 3, 2018
…dc-developers#2883)

AArch64 only supports .init_array, for example. The reason this wasn't discovered
earlier is that BFD and gold linkers automatically convert .ctors to .init_array
as a performance optimization.

Cherry-pick from issue ldc-developers#2883
kinke pushed a commit that referenced this pull request Nov 4, 2018
…r AArch64) (#2896)

Nothing to be fixed for master, as LLVM defaults to .init_array unless using an explicit
-use-ctors in the cmdline.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants