https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70216

--- Comment #10 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Rich Felker from comment #9)
> From a Linux standpoint, there is no trapa trap number defined that would
> cause a fatal signal. The ones that are defined are for syscalls and debug
> breakpoints. On the other hand, a permanently-undefined opcode would cause
> SIGILL. So for Linux targets with aim of generating code that does what you
> intend for it to do on both existing and future kernels, I think it makes
> much more sense to use FFFD. This also aligns with the behavior of
> __builtin_trap() on other targets, which is almost always to execute an
> instruction that causes SIGILL (or, if unavailable, SIGSEGV).
> 
> I'm not opposed to supporting a -m option to choose a trapa trap instead,
> and/or making something with trapa the default for freestanding/non-linux
> targets.

So my patch from Comment 6 could be extended to handle the option
  -mbuiltin-trap=insn-FFFD

and define that as the default for linux configs.

Would that do the job?


> FYI this issue is currently a regression that prevents building Linux with
> gcc7, since gcc7 introduced an optimization that transforms x/0 to
> __builtin_trap() rather than calling the libgcc div function.

It's OK to add __builtin_trap to GCC 7.
Could you have a look and try the patch in Comment 6?  I don't have so much
time for SH stuff these days...

Reply via email to