Bug 53641 (Changes) - gcc/config/i386/crtfastmath.c gives internal compiler error: Segmentation fault during make
Summary: gcc/config/i386/crtfastmath.c gives internal compiler error: Segmentation fau...
Status: RESOLVED INVALID
Alias: Changes
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.1.2
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-06-12 04:40 UTC by Prakash
Modified: 2012-06-12 06:02 UTC (History)
0 users

See Also:
Host:
Target:
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 Prakash 2012-06-12 04:40:34 UTC
I was trying to write a new pass in GCC 4.1.2 version but surprisingly I am getting abort during my GCC build. The new code which I have written has compiled but issues occurs while compiling gcc/config/i386/crtfastmath.c.


Below is th output I am trying via command line which is exactly what is run while make.

gcc/gcc-4.1.2 1011> /x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/xgcc -B/x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/ -B/usr/local/x86_64-unknown-linux-gnu/bin/ -B/usr/local/x86_64-unknown-linux-gnu/lib/ -isystem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-include -O2 -DIN_GCC -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -isystem -g -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -msse -save-temps -v -c gcc/config/i386/crtfastmath.c -o crtfastmath.o
Reading specs from /x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/specs
Target: x86_64-unknown-linux-gnu
Configured with: ./configure --with-gmp-lib=/usr/lib64 --with-mpfr-lib=/usr/lib64 --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
Thread model: posix
gcc version 4.1.2
 /x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/cc1 -E -quiet -v -iprefix /x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.1.2/ -isystem /x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/include -DIN_GCC -DHAVE_GTHR_DEFAULT -DIN_LIBGCC2 -D__GCC_FLOAT_NOT_NEEDED -isystem /usr/local/x86_64-unknown-linux-gnu/include -isystem /usr/local/x86_64-unknown-linux-gnu/sys-include -isystem -g gcc/config/i386/crtfastmath.c -msse -mtune=k8 -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -O2 -fpch-preprocess -o crtfastmath.i
ignoring nonexistent directory "/usr/local/x86_64-unknown-linux-gnu/include"
ignoring nonexistent directory "/usr/local/x86_64-unknown-linux-gnu/sys-include"
ignoring nonexistent directory "-g"
ignoring nonexistent directory "/x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.1.2/include"
ignoring nonexistent directory "/x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/../lib/gcc/x86_64-unknown-linux-gnu/4.1.2/../../../../x86_64-unknown-linux-gnu/include"
ignoring nonexistent directory "NONE/include"
ignoring nonexistent directory "/usr/local/lib/gcc/x86_64-unknown-linux-gnu/4.1.2/include"
ignoring nonexistent directory "/usr/local/lib/../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/include
 /usr/local/include
 /usr/include
End of search list.
 /x/home/satprasad/shared_scripts/bin/gcc/gcc-4.1.2/host-x86_64-unknown-linux-gnu/gcc/cc1 -fpreprocessed crtfastmath.i -quiet -dumpbase crtfastmath.c -msse -mtune=k8 -auxbase-strip crtfastmath.o -O2 -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -Wold-style-definition -version -o crtfastmath.s
GNU C version 4.1.2 (x86_64-unknown-linux-gnu)
        compiled by GNU C version 4.1.2 20080704 (Red Hat 4.1.2-46).
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 9c3542c4e389570e9f26c3f53d3037d2
gcc/config/i386/crtfastmath.c:110: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.



gcc/gcc-4.1.2 1014>  cat crtfastmath.i
# 1 "gcc/config/i386/crtfastmath.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "gcc/config/i386/crtfastmath.c"
# 40 "gcc/config/i386/crtfastmath.c"
static void __attribute__((constructor))
set_fast_math (void)
{
# 106 "gcc/config/i386/crtfastmath.c"
  unsigned int mxcsr = __builtin_ia32_stmxcsr ();
  mxcsr |= (1 << 6) | (1 << 15);
  __builtin_ia32_ldmxcsr (mxcsr);

}
gcc/gcc-4.1.2 1015> cat crtfastmath.s
        .file   "crtfastmath.c"
gcc/gcc-4.1.2 1016>


gcc/gcc-4.1.2 1016> uname -a
Linux xxxxxxx 2.6.18-164.el5 #1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU/Linux
gcc/gcc-4.1.2 1017>



One thing I am anot sure and would be worth mentioning that when I just have a fprintf("Test"); in my new pass - the error was not reproducable - though I am sure I have no issues with my pass. Below is the code:

gcc/gcc-4.1.2 1017> cat gcc/gimple-manipulation.c
#include "config.h"
#include "system.h"
#include "coretypes.h"
#include "tm.h"
#include "ggc.h"
#include "flags.h"
#include "tree.h"
#include "basic-block.h"
#include "tree-flow.h"
#include "tree-pass.h"
#include "tree-dump.h"
#include "timevar.h"
#include "diagnostic.h"
#include "cfgloop.h"
#include "tree-scalar-evolution.h"
#include "tree-ssa-propagate.h"
#include "tree-chrec.h"


static void execute_gimple_manipulation (void);
static bool gate_gimple_manipulation (void);

static void execute_gimple_manipulation (void)
{
  basic_block bb = ENTRY_BLOCK_PTR;
  int bbcounter=0, stmtcounter;
  tree stmt;
  block_stmt_iterator si;

  /* traverse each basic block and print all statements  */
  gcc_assert (cfun != NULL);
  gcc_assert (cfun && current_function_decl);

  FOR_EACH_BB (bb){ /* in any order */

    bbcounter++;
    printf("\n-> entering bb # %d (internal #: %d)\n", bbcounter, bb->index);

    stmtcounter=0;

    for(si = bsi_start(bb); !bsi_end_p(si); bsi_next(&si)){
      stmtcounter++;
      printf("   encountering statement #%2d: ", stmtcounter);
      stmt = bsi_stmt(si);
      print_generic_stmt (stderr, stmt, 0);
    }
  }
}

/* ------------------------------------------
   Return true if we should execute our pass.
   ------------------------------------------*/
static bool
gate_gimple_manipulation (void)
{
  return (!(errorcount || sorrycount));
}
struct tree_opt_pass pass_gimple_manipulation =
{
   "gm_pass_simple",             /* name */
   gate_gimple_manipulation,     /* gate */
   execute_gimple_manipulation,  /* execute */
   NULL,                         /* sub */
   NULL,                         /* next */
   0,                            /* static pass number */
   0,                            /* tv_id */
   PROP_cfg | PROP_ssa | PROP_alias,                            /* properties required */
   0,                            /* properties provided */
   0,                            /* properties destroyed */
   0,                            /* todo_flags start */
   TODO_dump_func,                            /* todo_flags finish */
   0                             /* letter */
};

Please let me know if you require any other info?
Comment 1 Prakash 2012-06-12 04:48:16 UTC
Replace 
=========================================
fprintf("Test");
with
fprintf(stderr, "This is a dummy line\n");
Comment 2 Andrew Pinski 2012-06-12 06:02:55 UTC
4.1.2 is old and we are not going to debug why your pass is not working.  I think it is time to pull out the old trusty gdb and see where the segfault is located at.

You also don't say where you place your pass.