Bug 725516 - gcc-4.6.1-3.fc16.x86_64 large O2 error: immediate operand illegal with absolute jump
Summary: gcc-4.6.1-3.fc16.x86_64 large O2 error: immediate operand illegal with absolu...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Fedora
Classification: Fedora
Component: gcc
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Jakub Jelinek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2011-07-25 18:29 UTC by Mads Kiilerich
Modified: 2011-08-22 15:27 UTC (History)
1 user (show)

Fixed In Version: gcc-4.6.1-7.fc16
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2011-07-27 13:21:29 UTC
Type: ---


Attachments (Terms of Use)


Links
System ID Private Priority Status Summary Last Updated
GNU Compiler Collection 49866 0 None None None Never

Description Mads Kiilerich 2011-07-25 18:29:41 UTC
While trying to update grub2 to grub-1.99 on x86_64 I got an assembler error which I reduced to the following. The original test case had no warnings and compiles without problems without O2 or with -mcmodel=large - and thus also on 32-bit.

$ cat test.c
static f0 (struct s *ps, int n)
{
  int i;
  for (i = 0; i < n; i++)
    {
      b (ps, c (), i);
    }
}
f (int p1, int edit, int n, struct s *ps)
{
  x (p1);
  f0 (ps, n);
  x (p1);
}

$ gcc -mcmodel=large -O2 -c test.c
test.c:1:19: warning: ‘struct s’ declared inside parameter list [enabled by default]
test.c:1:19: warning: its scope is only this definition or declaration, which is probably not what you want [enabled by default]
test.c:9:36: warning: ‘struct s’ declared inside parameter list [enabled by default]
test.c: In function ‘f’:
test.c:12:3: warning: passing argument 1 of ‘f0’ from incompatible pointer type [enabled by default]
test.c:1:8: note: expected ‘struct s *’ but argument is of type ‘struct s *’
test.s: Assembler messages:
test.s:70: Error: immediate operand illegal with absolute jump

gcc-4.6.1-3.fc16.x86_64
gcc (GCC) 4.6.1 20110715 (Red Hat 4.6.1-3)

Comment 1 Mads Kiilerich 2011-07-25 20:30:14 UTC
s/ with -mcmodel=large / without -mcmodel=large /

Comment 2 Jakub Jelinek 2011-07-27 13:21:29 UTC
Tracking upstream.  Why does grub use -mcmodel=large, out of curiosity?

Comment 3 Mads Kiilerich 2011-07-27 14:09:22 UTC
It seems to be assumed that it is required for 64bit EFI. I'm sure mjg59 know the details.

configure.ac:
if test "$target_cpu"-"$platform" = x86_64-efi; then
  # Use large model to support 4G memory
  AC_CACHE_CHECK([whether option -mcmodel=large works], grub_cv_cc_mcmodel, [
    SAVED_CFLAGS=$CFLAGS
    CFLAGS="$CFLAGS -m64 -mcmodel=large"
    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],
                      [grub_cv_cc_mcmodel=yes],
                      [grub_cv_cc_mcmodel=no])
  ])
  if test "x$grub_cv_cc_mcmodel" = xno; then
    AC_MSG_ERROR([-mcmodel=large not supported. Upgrade your gcc.])
  else
    TARGET_CFLAGS="$TARGET_CFLAGS -mcmodel=large"
  fi

grub-core/Makefile.am :
efiemu64_c.o: efiemu/runtime/efiemu.c
          $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -m64 -nostdlib -Wall -Werror -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \

efiemu64_s.o: efiemu/runtime/efiemu.S
          $(TARGET_CC) $(DEFS) $(INCLUDES) $(CPPFLAGS_EFIEMU) $(CPPFLAGS_DEFAULT) -DELF64 -m64 -Wall -Werror -nostdlib -O2 -mcmodel=large -mno-red-zone -c -o $@ $< || exit 1; \

(Grub has a lot of compile flags hardcoded. Some of them probably for good reasons, but it causes trouble when it is combined with standard rpm CFLAGS.)

Comment 4 Fedora Update System 2011-07-27 17:57:56 UTC
gcc-4.6.1-4.fc16 has been submitted as an update for Fedora 16.
https://admin.fedoraproject.org/updates/gcc-4.6.1-4.fc16

Comment 5 Fedora Update System 2011-08-22 15:26:48 UTC
gcc-4.6.1-7.fc16 has been pushed to the Fedora 16 stable repository.  If problems still persist, please make note of it in this bug report.


Note You need to log in before you can comment on or make changes to this bug.