Skip to content

Add support for alternate boost-context backends#30496

Merged
alalazo merged 3 commits intospack:developfrom
elfprince13:patch-2
May 6, 2022
Merged

Add support for alternate boost-context backends#30496
alalazo merged 3 commits intospack:developfrom
elfprince13:patch-2

Conversation

@elfprince13
Copy link
Copy Markdown
Contributor

The fcontext backend is the default high-performance backend.
The ucontext backend is needed when using Boost context in conjunction with ASAN.
The WinFibers backend...also exists.

cf. https://www.boost.org/doc/libs/1_79_0/libs/context/doc/html/context/cc/implementations__fcontext_t__ucontext_t_and_winfiber.html

The fcontext backend is the default high-performance backend.
The ucontext backend is needed when using Boost context in conjunction with ASAN.
The WinFibers backend...also exists.

cf. https://www.boost.org/doc/libs/1_79_0/libs/context/doc/html/context/cc/implementations__fcontext_t__ucontext_t_and_winfiber.html
Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

LGTM. Deferring merge decision to maintainers/package experts.

@tldahlgren tldahlgren self-assigned this May 5, 2022
@tldahlgren tldahlgren self-requested a review May 5, 2022 16:28
Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

Please correct the style error; otherwise, LGTM.

Copy link
Copy Markdown
Contributor

@hainest hainest left a comment

Choose a reason for hiding this comment

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

It would be great if we could get a list of the properties that b2 supports, but I couldn't find a listing in the docs. How did you find this one?

values=('fcontext','ucontext','winfib'),
multi=False,
description='Use the specified backend for boost-context',
when='+context')
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

What version of Boost introduced this feature? I'm working to make sure variants are correctly mapped to versions where they are actually available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

@hainest hainest May 5, 2022

Choose a reason for hiding this comment

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

I'll run my automated tests and check. edit: We don't need to hold this PR for this.

Copy link
Copy Markdown
Contributor Author

@elfprince13 elfprince13 May 5, 2022

Choose a reason for hiding this comment

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

Incidentally there's an option for supporting valgrind that would be great to get rolled in as well (as a separate PR):

https://www.boost.org/doc/libs/1_79_0/libs/context/doc/html/context/stack/valgrind.html

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, very nice! I will try to see about getting at least a reference list of the features/properties.

context_impl = spec.variants['context-impl'].value
if '+context' in spec and context_impl in {'ucontext', 'winfib'}:
options.extend(['context-impl=%s' % context_impl])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Assuming b2 won't raise any fuss if we pass context-impl=fcontext, there's no need to check for it here. That will remove this maintenance hazard in keeping the check here and the values of the variant in synch.

Suggested change
if '+context' in spec:
context_impl = spec.variants['context-impl'].value
options.append('context-impl=%s' % context_impl)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The documentation page I linked above only discusses the possibility of ucontext or winfib as arguments.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In 1.79.0,

$ ./bootstrap.sh --with-libraries=context

$ ./b2 context-impl=moo
/boost_1_79_0/tools/build/src/build/feature.jam:491: in validate-value-string from module feature
error: "moo" is not a known value of feature <context-impl>
error: legal values: "fcontext" "ucontext" "winfib"

$ ./b2 context-impl=fcontext
  ...
    - context                  : building
  ...
The Boost C++ Libraries were successfully built!

Let's assume for now that always works. I'll add it to my TODO list to double-check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Cool - i just verified fcontext is present as an option at least as far back as 1.65:
https://github.com/boostorg/context/blob/boost-1.65.0/build/Jamfile.v2

I'll go ahead and remove that extra check.

I will note that the special-casing for the defines introduced in 65d7b34 should be kept as BOOST_USE_FCONTEXT is not used anywhere.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh, that's... neat. Particularly since ucontext was removed in POSIX.1-2008. Boost, why did you do that?!

Out of curiosity, which backend are you using?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fcontext is definitely the sensible default for most use-cases, but ucontext is the only way to cooperate with ASAN if you're doing memory debugging (or was - it seems to have broken at some point recently since ASAN promptly reported a bug in boost itself when I switched)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Oh sorry, yes, you mentioned that in your commit. It's interesting ASAN is relying on the deprecated/removed interface. I would assume it's really difficult to instrument the fcontext usage.

Whitespace fixes.
Also improve the client interface somewhat by setting the appropriate flags in the build environment.
tldahlgren
tldahlgren previously approved these changes May 5, 2022
Copy link
Copy Markdown
Contributor

@tldahlgren tldahlgren left a comment

Choose a reason for hiding this comment

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

Removing my blocking review related to style check.

Also adds explanatory comments for the special-casing that remains.
@hainest
Copy link
Copy Markdown
Contributor

hainest commented May 5, 2022

Looks like the pipeline is stuck.

@spackbot re-run pipeline

@spackbot-app
Copy link
Copy Markdown

spackbot-app bot commented May 5, 2022

I had a problem triggering the pipeline.

@alalazo alalazo merged commit 6c6685b into spack:develop May 6, 2022
elfprince13 added a commit to Geopipe/spack that referenced this pull request May 9, 2022
The fcontext backend is the default high-performance backend.
The ucontext backend is needed when using Boost context in conjunction with ASAN.
The WinFibers backend...also exists.

https://www.boost.org/doc/libs/1_79_0/libs/context/doc/html/context/cc/implementations__fcontext_t__ucontext_t_and_winfiber.html
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.

4 participants