Bug 79560 - libgccjit is broken on generic mips targets
Summary: libgccjit is broken on generic mips targets
Status: UNCONFIRMED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 7.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-16 17:54 UTC by James Cowgill
Modified: 2017-02-17 08:38 UTC (History)
2 users (show)

See Also:
Host:
Target: mips
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description James Cowgill 2017-02-16 17:54:45 UTC
Originally from https://bugs.debian.org/798710

On generic MIPS targets (ie something like mipsel-linux-gnu), libgccjit does not work. Running the "Smoketest example" from https://gcc.gnu.org/onlinedocs/jit/intro/tutorial01.html gives this:
                                                                                                                         
> $ ./jit-test
> /tmp/libgccjit-m3qxk4/fake.s: Assembler messages:
> /tmp/libgccjit-m3qxk4/fake.s:16: Error: `fp=xx' used with a cpu lacking ldc1/sdc1 instructions
> /tmp/libgccjit-m3qxk4/fake.s:16: Error: `fp=xx' used with a cpu lacking ldc1/sdc1 instructions
> /tmp/libgccjit-m3qxk4/fake.s:17: Error: `fp=xx' used with a cpu lacking ldc1/sdc1 instructions
> /tmp/libgccjit-m3qxk4/fake.s:24: Error: `fp=xx' used with a cpu lacking ldc1/sdc1 instructions
> /tmp/libgccjit-m3qxk4/fake.s:26: Error: `fp=xx' used with a cpu lacking ldc1/sdc1 instructions
> /tmp/libgccjit-m3qxk4/fake.s:50: Error: `fp=xx' used with a cpu lacking ldc1/sdc1 instructions
> /tmp/libgccjit-m3qxk4/fake.s:51: Error: `fp=xx' used with a cpu lacking ldc1/sdc1 instructions
> libgccjit.so: error: error invoking gcc driver
> NULL result

Running the smoke test on a 64-bit target gives (and we'll ignore the binutils error for now...):
> $ ./jit-test
> Assembler messages:
> Error: -march=mips1 is not compatible with the selected ABI
> /tmp/libgccjit-LqHWBT/fake.s:16: Error: `gp=32' used with a 64-bit ABI
> /tmp/libgccjit-LqHWBT/fake.s:16: Error: `fp=64' used with a 32-bit fpu
> /tmp/libgccjit-LqHWBT/fake.s:16: Error: `fp=64' used with a 32-bit fpu
> /tmp/libgccjit-LqHWBT/fake.s:17: Error: `fp=64' used with a 32-bit fpu
> /tmp/libgccjit-LqHWBT/fake.s:24: Error: `fp=64' used with a 32-bit fpu
> /tmp/libgccjit-LqHWBT/fake.s:25: Error: `fp=64' used with a 32-bit fpu
> /tmp/libgccjit-LqHWBT/fake.s:26: Error: opcode not supported on this processor: mips1 (mips1) `daddiu $sp,$sp,-48'
> /tmp/libgccjit-LqHWBT/fake.s:27: Warning: macro instruction expanded into multiple instructions
> /tmp/libgccjit-LqHWBT/fake.s:28: Warning: macro instruction expanded into multiple instructions
> /tmp/libgccjit-LqHWBT/fake.s:29: Warning: macro instruction expanded into multiple instructions
> /tmp/libgccjit-LqHWBT/fake.s:32: Error: opcode not supported on this processor: mips1 (mips1) `daddu $28,$28,$25'
> /tmp/libgccjit-LqHWBT/fake.s:33: Error: opcode not supported on this processor: mips1 (mips1) `daddiu $28,$28,%lo(%neg(%gp_rel(greet)))'
> /tmp/libgccjit-LqHWBT/fake.s:34: Warning: macro instruction expanded into multiple instructions
> /tmp/libgccjit-LqHWBT/fake.s:35: Warning: macro instruction expanded into multiple instructions
> /tmp/libgccjit-LqHWBT/fake.s:36: Internal error!
> Assertion failure in macro_build at ../../gas/config/tc-mips.c:8655.
> Please report this bug.
> libgccjit.so: error: error invoking gcc driver
> NULL result

This seems to be because libgccjit always passes -mips1 to the driver which is obviously wrong. In the Debian bug report, this was traced to add_multilib_driver_arguments where the contents of MULTILIB_DEFAULTS is passed to the driver. On MIPS this always includes the ISA level obtained from MIPS_ISA_DEFAULT, but on generic MIPS targets this is not defined and it falls back to mips1.

I am wondering why MIPS_ISA_DEFAULT is even included in MULTILIB_DEFAULTS? If I remove the ISA, libgccjit works again (or at least the smoke test works).