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

Use environment for mips feature detection #3630

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Commits on Mar 2, 2023

  1. Use environment for mips feature detection

    The -march= option is perfectly happy to emit code to run on a processor
    different than the one on which it is being compiled.  This results in
    misdetection of mips features because the test compiles specify that a
    given extension should be emitted, but this does not check whether or
    not this corresponds to the subarchitecture targeted in CFLAGS by the
    rest of the build.
    
    $ echo "void main(void){ __asm__ volatile(\"punpcklhw \$f0, \$f0, \$f0\"); }" > test.c
    $ CFLAGS="-march=loongson3a" make test
    cc -march=loongson3a    test.c   -o test
    $ ./test
    Illegal instruction
    $ CFLAGS="-march=native" make -B test
    cc -march=native    test.c   -o test
    /tmp/ccLbeyM1.s: Assembler messages:
    /tmp/ccLbeyM1.s:25: Error: opcode not supported on this processor: octeon2 (mips64r2) `punpcklhw $f0,$f0,$f0'
    make: *** [<builtin>: test] Error 1
    
    This leads to -march=loongson3a getting appended to CFLAGS, which may
    conflict with previously specified -march= levels for the build, or
    other options.  Calling make in the test will use whatever CC/CFLAGS are
    specified in the environment to determine whether the actual compile
    command line to be used in the build supports these features.
    
    Fixes: 8b942ee ("Adjust the mmi/msa detection mode for mips platform.")
    matoro committed Mar 2, 2023
    Configuration menu
    Copy the full SHA
    f60e7d9 View commit details
    Browse the repository at this point in the history