This is an archive of the discontinued LLVM Phabricator instance.

OpenBSD add C++ runtime in a driver's standpoint
ClosedPublic

Authored by devnexen on Apr 14 2018, 11:23 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

devnexen created this revision.Apr 14 2018, 11:23 PM
dberris added inline comments.Apr 15 2018, 5:41 PM
lib/Driver/ToolChains/CommonArgs.cpp
678–679 ↗(On Diff #142541)

Maybe this should be in the TC.AddCXXStdlibLibArgs(...) function instead?

devnexen added inline comments.Apr 15 2018, 10:15 PM
lib/Driver/ToolChains/CommonArgs.cpp
678–679 ↗(On Diff #142541)

I did not dare since it s the only case where it is needed (e.g. no need for X-ray for example)

dberris added inline comments.Apr 15 2018, 11:08 PM
lib/Driver/ToolChains/CommonArgs.cpp
678–679 ↗(On Diff #142541)

Okay, let me ask this another way.

Is there ever a case for OpenBSD when we're doing TC.AddCXXStdlibLibArgs(...) that we don't need to also add these flags when OPT_pg is specified?

devnexen added inline comments.Apr 15 2018, 11:14 PM
lib/Driver/ToolChains/CommonArgs.cpp
678–679 ↗(On Diff #142541)

I see ... will do another version then :-)

alexfh removed a reviewer: alexfh.Apr 16 2018, 3:48 AM
devnexen updated this revision to Diff 142686.Apr 16 2018, 1:24 PM
  • Putting the change on the driver itself.

Okay, can you help me understand why this isn't required for builds in OpenBSD which don't use sanitizers, but want C++ builds that also add the -pg flag? I would have thought that those situations would break, no?

devnexen updated this revision to Diff 142740.Apr 16 2018, 11:38 PM
  • Making base gcc 4.2.1 stdc++ having profile version supported as well.
dberris added inline comments.Apr 16 2018, 11:52 PM
lib/Driver/ToolChains/OpenBSD.cpp
189 ↗(On Diff #142740)

Do you actually need this change? Why isn't getToolChain().AddCXXStdlibLibArgs(...) not sufficient here?

197–199 ↗(On Diff #142740)

Doesn't the common args implementation already handle this case? What am I missing?

265–269 ↗(On Diff #142740)

Almost there -- but I think you want to look at the implementation of something like the FreeBSD driver which does a suitably complete definition, which supports either libstdc++ or libc++.

That way you don't need the other change specific to when you need the sanitizer deps, and rely on the default implementation for LibFuzzer in CommonArgs. No?

Am looking at https://clang.llvm.org/doxygen/FreeBSD_8cpp_source.html#l00345 for reference.

devnexen added inline comments.Apr 17 2018, 12:49 AM
lib/Driver/ToolChains/OpenBSD.cpp
189 ↗(On Diff #142740)

That s the thing, I wish it was simple as FreeBSD, but seemingly in OpenBSD needs both c++98 gcc runtime and libc++ for fuzzer (I tried libc++ alone already)

dberris added inline comments.Apr 17 2018, 12:51 AM
lib/Driver/ToolChains/OpenBSD.cpp
189 ↗(On Diff #142740)

Right, but this comment is on this specific line change. I don't think you need to reach into Toolchain. direcly, since you can already use getToolChain() just from the above line (188).

devnexen added inline comments.Apr 17 2018, 12:55 AM
lib/Driver/ToolChains/OpenBSD.cpp
189 ↗(On Diff #142740)

Right, so I guess this diff https://reviews.llvm.org/D45662?id=142686 is sufficient then ?

dberris added inline comments.Apr 17 2018, 1:03 AM
lib/Driver/ToolChains/OpenBSD.cpp
189 ↗(On Diff #142740)

No. Let me try and explain again.

You were on the right path, with overriding the AddCXXStdlibLibArgs function in the OpenBSD Toolchain type. It's just that you weren't handling the case for when the binary was being built with libc++ or libstdc++ properly. I was referring you to what FreeBSD was doing for their implementation of AddCXXStdlibLibArgs. This means, checking first whether the invocation of the compiler was using libc++ or libstdc++, and then adding the appropriate link spelling. That all happens in the AddCXXStdlibLibArgs implementation, because there's no need to special-case just for the sanitizers.

This means, if you're building a normal binary with -pg in OpenBSD against either libc++ or libstdc++, it wouldn't work correctly regardless of whether you were using libFuzzer.

Does that make more sense?

devnexen added inline comments.Apr 17 2018, 1:08 AM
lib/Driver/ToolChains/OpenBSD.cpp
189 ↗(On Diff #142740)

Ok will try a newer version later, thanks for your inputs.

devnexen updated this revision to Diff 142811.Apr 17 2018, 11:56 AM
devnexen retitled this revision from Fuzzer, add libcxx for OpenBSD to OpenBSD add C++ runtime in a driver's standpoint.
devnexen edited the summary of this revision. (Show Details)
devnexen added inline comments.Apr 17 2018, 11:59 AM
lib/Driver/ToolChains/OpenBSD.cpp
189 ↗(On Diff #142740)

So I looked at FreeBSD and makes more sense by default it s libcxx since the 10.x releases. A release has a few years span of support. OpenBSD has complete different release policy, much shorter and two releases per year. clang been in since 6.2 (and we re at 6.3 now and the time llvm 7 comes out it will be 6.4).

devnexen added inline comments.Apr 17 2018, 12:02 PM
lib/Driver/ToolChains/OpenBSD.cpp
189 ↗(On Diff #142740)

To complete a bit above explanation, softwares of certain version matches the OS version. In other words there won t be llvm 7 for OpenBSD 6.1

dberris accepted this revision.Apr 17 2018, 4:16 PM

LGTM

Thanks for working through this @devnexen!

I can land this a little later on my day (Sydney, Australia).

This revision is now accepted and ready to land.Apr 17 2018, 4:16 PM
This revision was automatically updated to reflect the committed changes.