fix compilation failure on OpenBSD with system supplied GNU C 4.2.1
ClosedPublic

Authored by kgardas on Aug 13 2016, 11:47 AM.

Details

Summary

This patch fixes compilation failure on OpenBSD. The OpenBSD's
GNU C compiler is of 4.2.1 version and problematic builtin_unreachable
was added in GNU C 4.5 release. Let's use pure abort() call
on OpenBSD instead of
builtin_unreachable

Diff Detail

Repository
rGHC Glasgow Haskell Compiler
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
kgardas updated this revision to Diff 8409.Aug 13 2016, 11:47 AM
kgardas retitled this revision from to fix compilation failure on OpenBSD with system supplied GNU C 4.2.1.
kgardas updated this object.
kgardas edited the test plan for this revision. (Show Details)
kgardas added reviewers: austin, bgamari.
erikd requested changes to this revision.Aug 13 2016, 4:28 PM
erikd edited edge metadata.
erikd added inline comments.
rts/sm/CNF.c
168

I'd much prefer this to be #elif defined openbsd_HOST_OS to avoid needlessly nested #ifdef.

This revision now requires changes to proceed.Aug 13 2016, 4:28 PM

@erikd will do tomorrow in the evening (CEST). Thanks for the comment.

kgardas updated this revision to Diff 8412.Aug 14 2016, 6:28 AM
kgardas edited edge metadata.

Do not use openbsd_HOST_OS #ifdef but rather test for specific GNU C version

kgardas marked an inline comment as done.EditedAug 14 2016, 6:29 AM

I've changed the #ifdef a bit to test for specific GNU C version. Also I've reformatted code as per Eric's advice. I've tested on OpenBSD-current with its GNU C 4.2.1 and verified I get to abort() code branch and on Solaris 11 with GNU C 4.8.2 and verified that I get to __builtin_unreachable code branch so #ifdef machinery should be ok. Thanks for review and comments.

erikd accepted this revision.Aug 14 2016, 2:54 PM
erikd edited edge metadata.

LGTM!

This revision is now accepted and ready to land.Aug 14 2016, 2:54 PM
This revision was automatically updated to reflect the committed changes.
simonmar added inline comments.Aug 15 2016, 11:25 AM
rts/sm/CNF.c
167–172

It would be better to put this in a macro in Rts.h, where we have various other gcc-version-specific macros, e.g. https://phabricator.haskell.org/diffusion/GHC/browse/master/includes/Rts.h;fc1432aa57b01c1e3b936dcee0eb419a8c2bb2c8$58-62

@simonmar Good catch! Working on that. I'm not sure I can update closed Dx, so I'll try to provide a new one.

@simonmar the macro is done in D2457