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

Conversation

matoro
Copy link

@matoro matoro commented Mar 2, 2023

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.

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 added a commit to matoro/gentoo that referenced this pull request Mar 15, 2023
Patch backports cisco/openh264#3630

Tests are currently broken on BE but pass on LE.

cisco/openh264#3634

Bug: https://bugs.gentoo.org/896138
Signed-off-by: Matoro Mahri <[email protected]>
matoro added a commit to matoro/gentoo that referenced this pull request Mar 15, 2023
Patch backports cisco/openh264#3630

Tests are currently broken on BE but pass on LE.

cisco/openh264#3634

Bug: https://bugs.gentoo.org/896138
Signed-off-by: Matoro Mahri <[email protected]>
matoro added a commit to matoro/gentoo that referenced this pull request Mar 15, 2023
Patch backports cisco/openh264#3630

Tests are currently broken on BE but pass on LE.

cisco/openh264#3634

Bug: https://bugs.gentoo.org/896138
Signed-off-by: Matoro Mahri <[email protected]>
gentoo-bot pushed a commit to gentoo/gentoo that referenced this pull request Mar 15, 2023
Patch backports cisco/openh264#3630

Tests are currently broken on BE but pass on LE.

cisco/openh264#3634

Bug: https://bugs.gentoo.org/896138
Signed-off-by: Matoro Mahri <[email protected]>
Closes: #30137
Signed-off-by: Joonas Niilola <[email protected]>
@LodewijkIVX
Copy link

;-)

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

Successfully merging this pull request may close these issues.

2 participants