Skip to content
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

sage_build_cython: Do not rely on CC environment variable being set #30876

Closed
mkoeppe opened this issue Nov 9, 2020 · 27 comments
Closed

sage_build_cython: Do not rely on CC environment variable being set #30876

mkoeppe opened this issue Nov 9, 2020 · 27 comments

Comments

@mkoeppe
Copy link
Member

mkoeppe commented Nov 9, 2020

(from #30580):

src/sage_setup/command/sage_build_cython.py contains this code:

# Work around GCC-4.8 bug which miscompiles some sig_on() statements:
# * https://github.com/sagemath/sage-prod/issues/14460
# * https://github.com/sagemath/sage-prod/issues/20226
# * http://gcc.gnu.org/bugzilla/show_bug.cgi?id=56982
if subprocess.call("""$CC --version | grep -i 'gcc.* 4[.]8' >/dev/null """, shell=True) == 0:
    extra_compile_args.append('-fno-tree-copyrename')

This gives an (ignored) error when CC is not set -- which can happen if invoked outside of sage-env, for example when building an sdist.

$ python3 -u setup.py --no-user-cfg sdist >/tmp/res
/bin/sh: 1: --version: not found

We remove this code, which is obsolete after #33316 (Drop support for GCC < 6.3 in Sage 9.7)

CC: @dimpase @orlitzky @kiwifb

Component: build

Author: Matthias Koeppe

Branch/Commit: 805bf82

Reviewer: François Bissey

Issue created by migration from https://trac.sagemath.org/ticket/30876

@mkoeppe mkoeppe added this to the sage-9.3 milestone Nov 9, 2020
@dimpase
Copy link
Member

dimpase commented Nov 9, 2020

comment:1

What does happen if CC is not set, how is setup.py getting the compilers to use? Via distutils?
Can't CC be set in setup.py if needed?

@mkoeppe
Copy link
Member Author

mkoeppe commented Nov 9, 2020

comment:2

Yes, distutils. So distutils should also be used to construct the command line for this version test.

@dimpase
Copy link
Member

dimpase commented Nov 9, 2020

comment:3

it looks doable, but ugly as hell:

from distutils.ccompiler import new_compiler, get_default_compiler
new_compiler(get_default_compiler()).compile(["foo.c"])

and then

$ strings hello.o | grep GCC
GCC: (Gentoo 8.3.1-r2 p4) 8.3.1 20190518

allows version extraction.

Wouldn't it be easier to, e.g., parse the banner of Python?

$ python
Python 3.7.9 (default, Sep 15 2020, 15:01:07) 
[GCC 8.3.1 20190518] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

@mkoeppe
Copy link
Member Author

mkoeppe commented Nov 9, 2020

comment:4

I think the call to gcc --version can be implemented in a simple and clean way in sage_build_ext, which has access to self.compiler.compiler

@dimpase
Copy link
Member

dimpase commented Nov 12, 2020

comment:5

If I do

>>> cc=new_compiler(get_default_compiler())
>>> _=cc.compile(["foo.c"], extra_preargs=['-dumpversion'])
8.3.1

then I see the version value. So one can wrap this in a script.
(one can also use --version instead of -dumpversion for a longer output.)

@dimpase
Copy link
Member

dimpase commented Nov 12, 2020

comment:6

I've also asked on stackoverflow, nobody knows...
https://stackoverflow.com/questions/64768024/finding-distutils-c-compiler-version

@mkoeppe
Copy link
Member Author

mkoeppe commented Mar 24, 2021

comment:7

Sage development has entered the release candidate phase for 9.3. Setting a new milestone for this ticket based on a cursory review of ticket status, priority, and last modification date.

@mkoeppe mkoeppe modified the milestones: sage-9.3, sage-9.4 Mar 24, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.4, sage-9.5 Aug 9, 2021
@orlitzky
Copy link
Contributor

orlitzky commented Dec 4, 2021

comment:9

We already reject gcc-4.7 and older in spkg-configure.m4. Would anyone notice if we rejected 4.8 (May, 2014) as well?

And if we do want to continue supporting gcc-4.8 from the system, couldn't we append -fno-tree-copyrename to CFLAGS to fix this? The optimization is buggy in 4.8.x so I don't think it's unjustified.

@mkoeppe
Copy link
Member Author

mkoeppe commented Dec 4, 2021

comment:10

Replying to @orlitzky:

Would anyone notice if we rejected 4.8 (May, 2014) as well?

Yes, this is the compiler on ubuntu-trusty and centos-7, which are still widely used.

We are dropping support for a platform with gcc 4.9 (debian-jessie) in Sage 9.5 (for #25009) because it turns to be more broken than 4.8.

@mkoeppe
Copy link
Member Author

mkoeppe commented Dec 4, 2021

comment:11

A trivial fix is to just replace $CC by ${CC-gcc}

@dimpase
Copy link
Member

dimpase commented Dec 4, 2021

comment:12

nobody nowadays is using gcc 4 on Centos 7. There are system packages to get you gcc 9. cf. e.g. https://stackoverflow.com/a/67212990/557937

Same story with Ubuntu, more or less.
https://askubuntu.com/a/1149383/309919

We can and should drop gcc 4, without dropping OSs.

@mkoeppe
Copy link
Member Author

mkoeppe commented Dec 4, 2021

comment:13

We can and should add variants of fedora/centos with devtoolset to our tox/GH Actions. So far this is neither tested nor documented anywhere.

@mkoeppe
Copy link
Member Author

mkoeppe commented Dec 4, 2021

comment:14

I've opened #32965/#32966 for this.

@dimpase
Copy link
Member

dimpase commented Dec 4, 2021

comment:15

probably even more relevant than these semi-vanilla cases would be the Azure docker container used in cibuildwheel to build manylinux wheels.

@mkoeppe mkoeppe modified the milestones: sage-9.5, sage-9.6 Dec 18, 2021
@mkoeppe mkoeppe modified the milestones: sage-9.6, sage-9.7 May 3, 2022
@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 31, 2022

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 31, 2022

Commit: 53c55d2

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 31, 2022

New commits:

fd0a71fsrc/sage_setup/command/sage_build_cython.py: Use gcc if CC unset
53c55d2src/sage_setup/command/sage_build_cython.py: Remove workaround for GCC 4.8

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 31, 2022

Author: Matthias Koeppe

@mkoeppe

This comment has been minimized.

@kiwifb
Copy link
Member

kiwifb commented Jul 31, 2022

comment:21

Is the branch really in the state you want? The last commit basically remove the content of the previous one. Otherwise I am all for removing useless bits.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 31, 2022

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

805bf82src/sage_setup/command/sage_build_cython.py: Remove workaround for GCC 4.8

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jul 31, 2022

Changed commit from 53c55d2 to 805bf82

@mkoeppe
Copy link
Member Author

mkoeppe commented Jul 31, 2022

comment:23

Thanks. I've squashed/rebased it. Yes, all of it can go away

@kiwifb
Copy link
Member

kiwifb commented Jul 31, 2022

Reviewer: François Bissey

@kiwifb
Copy link
Member

kiwifb commented Jul 31, 2022

comment:24

We should really get that in quick. It has been waiting long enough.

@mkoeppe
Copy link
Member Author

mkoeppe commented Aug 1, 2022

comment:25

Thanks!

@vbraun
Copy link
Member

vbraun commented Aug 4, 2022

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants