Thanks to visit codestin.com
Credit goes to github.com

Skip to content

MAINT: only add --std=c99 where needed #15238

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

Merged
merged 2 commits into from
Jan 5, 2020
Merged

Conversation

mattip
Copy link
Member

@mattip mattip commented Jan 4, 2020

Revert gh-15194, redo gh-14471

We really only need --std=c99 for pocketfft compilation, so do not add it unilaterally. Add the flag via setup.py. As pointed out in scipy/scipy#11270, this also turns on different floating point excess precision handling on 387 FPU.

@mattip mattip added 03 - Maintenance 09 - Backport-Candidate PRs tagged should be backported labels Jan 4, 2020
@mattip mattip requested a review from pv January 4, 2020 21:00
@pv
Copy link
Member

pv commented Jan 4, 2020

I'm not sure that is a robust way to do compiler detection, since I'm not sure the platform module and distutils agree.

I'd suggest instead to do in the top-level setup.py:

def get_build_ext_override():
    from numpy.distutils.commands.build_ext import build_ext as old_build_ext
    class build_ext(old_build_ext):
        def build_extension(self, ext):
            <add compiler flags to ext.extra_compile_args here>
            old_build_ext.build_extension(self, ext)
    return build_ext
...

def setup_package():
...
    metadata = dict(
...
        cmdclass={"sdist": sdist_checked,
            'build_ext': get_build_ext_override()},
...

to override just the compiler flags used when building the extensions. This is what @peterbell10 did for Scipy, and I guess it should also work here.

The design of distutils is again a problem here that makes solutions hacky.

@mattip
Copy link
Member Author

mattip commented Jan 4, 2020

The CI run with gcc 4.8 agrees that it is not enough to add the flag for pocketfft and random, we need it for all c-extensions.

@mattip
Copy link
Member Author

mattip commented Jan 5, 2020

Turns out we need to override both build_clib and build_ext

@mattip
Copy link
Member Author

mattip commented Jan 5, 2020

the build with gcc 4.8 passes.

Copy link
Member

@pv pv left a comment

Choose a reason for hiding this comment

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

LGTM.

@eric-wieser
Copy link
Member

Will this correctly apply the flag for the configtest stuff too?

def _is_using_gcc(obj):
is_gcc = False
if obj.compiler.compiler_type == 'unix':
cc = sysconfig.get_config_var("CC")
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't we be looking at obj.compiler to learn this, rather than global state that may not be equivalent?

Copy link
Member

@pv pv Jan 5, 2020

Choose a reason for hiding this comment

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

Distutils itself does it like this (grep for is_gcc). But I'm not sure if there is some reason why, as indeed the compiler object already knows its command line.

Copy link
Member Author

Choose a reason for hiding this comment

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

once burned twice shy: I prefer to mimic distutils as far as possible

@pv
Copy link
Member

pv commented Jan 5, 2020

It won't apply to configtest I think, as that's done by an earlier config command, but not sure if the flag is necessary there. Might also be possible to override the config command here.

@charris charris added this to the 1.18.1 release. milestone Jan 5, 2020
@charris charris merged commit 5184eb3 into numpy:master Jan 5, 2020
@charris
Copy link
Member

charris commented Jan 5, 2020

Thanks Matti. I don't think the config tests need the flag, but it may be worth tracking down the call in case that changes in the future.

@charris charris removed the 09 - Backport-Candidate PRs tagged should be backported label Jan 5, 2020
@charris charris removed this from the 1.18.1 release. milestone Jan 5, 2020
@mattip mattip deleted the redo-c99 branch November 2, 2020 08:29
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