This is an archive of the discontinued LLVM Phabricator instance.

[libcxx] Update gen_link_script.py to support different input and output
ClosedPublic

Authored by phosek on Apr 4 2019, 11:31 PM.

Diff Detail

Repository
rCXX libc++

Event Timeline

phosek created this revision.Apr 4 2019, 11:31 PM

This was extracted out of D54726 since it turned out to be useful for D60253.

thakis added a subscriber: thakis.Apr 5 2019, 6:24 AM

Nice! argparse makes this a lot simpler :)

libcxx/utils/gen_link_script.py
7 ↗(On Diff #193837)

I think the LHS license is the new license – probably want to keep the new license?

36 ↗(On Diff #193837)

stray debugging leftover?

38 ↗(On Diff #193837)

The LHS didn't do this. Is this for Windows?

41 ↗(On Diff #193837)

Probably don't want to do this if args.dryrun

62 ↗(On Diff #193837)

We're losing this error, is this intentional?

phosek updated this revision to Diff 193914.Apr 5 2019, 11:12 AM
phosek marked 6 inline comments as done.
ldionne accepted this revision.Apr 5 2019, 11:38 AM

While we're at it, do you know why the LIBCXX_ENABLE_ABI_LINKER_SCRIPT isn't allowed on Apple platforms? It doesn't seem to me like this is something you'd want to necessarily prevent on Apple platforms.

This revision is now accepted and ready to land.Apr 5 2019, 11:38 AM

While we're at it, do you know why the LIBCXX_ENABLE_ABI_LINKER_SCRIPT isn't allowed on Apple platforms? It doesn't seem to me like this is something you'd want to necessarily prevent on Apple platforms.

Linker scripts aren't a thing on Darwin, are they?

Looks good to me too except for the elif not os.path.exists(args.input): which I don't understand what it's for.

libcxx/utils/gen_link_script.py
38 ↗(On Diff #193837)

(unreplied)

62 ↗(On Diff #193837)

We're still losing this? I assume it's intentional, but might want to say why you're changing behavior here somewhere.

While we're at it, do you know why the LIBCXX_ENABLE_ABI_LINKER_SCRIPT isn't allowed on Apple platforms? It doesn't seem to me like this is something you'd want to necessarily prevent on Apple platforms.

Linker scripts aren't a thing on Darwin, are they?

My point is just that you might want to create/test the creation of the linker script on Darwin. Also, you could potentially be building for a Unix on an Apple platform.

While we're at it, do you know why the LIBCXX_ENABLE_ABI_LINKER_SCRIPT isn't allowed on Apple platforms? It doesn't seem to me like this is something you'd want to necessarily prevent on Apple platforms.

Linker scripts aren't a thing on Darwin, are they?

My point is just that you might want to create/test the creation of the linker script on Darwin. Also, you could potentially be building for a Unix on an Apple platform.

I mean crosscompiling _from_ an Apple platform.

The restriction just appeared artificial to me, that's all.

phosek added inline comments.Apr 5 2019, 1:05 PM
libcxx/utils/gen_link_script.py
7 ↗(On Diff #193837)

That's unintentional, I just copied the file from the original patch and forgot to update the header.

38 ↗(On Diff #193837)

It's for the static case, where the input would be libc++static.a and output would be libc++.a, but libc++.a is what's actually being produced by the CMake, in that case the script is going to rename libc++.a to libc++static.a and generate libc++.a linker script. The --input and --output argument names are a bit misleading in that case, maybe something like --library and --link-script would be better?

62 ↗(On Diff #193837)

This is intentional because in cases like the static library, there's no symlink.

phosek added a comment.Apr 5 2019, 1:09 PM

I mean crosscompiling _from_ an Apple platform.

The restriction just appeared artificial to me, that's all.

Cross-compiling works, we use it in our build when building Fuchsia runtimes on Apple platforms, so it's only when targeting Apple platform that's unsupported.

phosek marked an inline comment as done.Apr 5 2019, 6:35 PM
phosek added inline comments.
libcxx/utils/gen_link_script.py
38 ↗(On Diff #193837)

I forgot to press reply.

thakis accepted this revision.Apr 5 2019, 7:41 PM

Might want to mention in the commit message that this adds support for the static library chase. Is there no way to make cmake call the static lib c++static.a though? Having this script rename the build system's build output is a bit weird.

phosek updated this revision to Diff 196123.Apr 22 2019, 12:48 PM

Might want to mention in the commit message that this adds support for the static library chase. Is there no way to make cmake call the static lib c++static.a though? Having this script rename the build system's build output is a bit weird.

I've cleaned up that part of the script since we don't really need the static library support yet.

This revision was automatically updated to reflect the committed changes.