編譯低版本Gcc (

說在前面

這個問題發生在我使用Mac源碼方式編譯gcc3.4.1時發生的(Windows 上使用Cygwin安裝也會有相同報錯~),完整的報錯爲:

../../gcc/config/darwin-crt2.c: In function `__darwin_gcc3_preregister_frame_info':
../../gcc/config/darwin-crt2.c:156: error: unrecognizable insn:
(insn 11 9 12 0 (set (reg/f:SI 58)
        (plus:SI (reg:SI 3 bx)
            (const:SI (minus:SI (symbol_ref:SI ("&L___keymgr_global$non_lazy_ptr"))
                    (symbol_ref:SI ("<pic base>")))))) -1 (nil)
    (nil))
../../gcc-3.4.1/gcc/config/darwin-crt2.c:151: internal compiler error: in extract_insn, at 
recog.c:2083
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make[2]: *** [crt2.o] Error 1
make[1]: *** [stage1_build] Error 2
make: *** [bootstrap] Error 2

出現這個的過程是我執行了

../configure --prefix=$PREFIX  --with-gmp=$(brew-path gmp) --with-mpfr=$(brew-path mpfr) --with-mpc=$(brew-path libmpc) --program-suffix=-$VERSION  --enable-languages=$LANGUAGES --with-system-zlib --enable-stage1-checking --enable-plugin --enable-lto  --disable-multilib
make bootstrap
make install

另:關於Mac如何使用源碼方式編譯Gcc 請參照Mac安裝GCC (使用時 發現wget並不好用,所以直接下載了壓縮包,本地解鎖使用的。效用相同)

如需轉載,請註明出自喵喵丸的Blog

解決方案

已經是10多年前的解決貼了(此處不禁在想我到底找了什麼陳年的東西來編譯),下面兩個網址是gnu.org上面找到的解決方法,親測可用。
問題的引入
問題的解決

這裏我來做一個簡單的流程引導。
① 請將 make 之前的行爲都做完(即是 執行完 ./configure xxxxxxxx之後)
② 找到入下圖所示的 i386.c文件
目錄示意
③ 修改該文件內容
首先找到下面的代碼段

      /* Offsets of TLS symbols are never valid.
     Discourage CSE from creating them.  */
      if (GET_CODE (inner) == PLUS
      && tls_symbolic_operand (XEXP (inner, 0), Pmode))
    return false;

在之後添加

    /* Allow {LABEL | SYMBOL}_REF - SYMBOL_REF-FOR-PICBASE for Mach-O.  */
 if (TARGET_MACHO && GET_CODE (inner) == MINUS)
   {
     if (GET_CODE (XEXP (inner, 0)) == LABEL_REF
   || GET_CODE (XEXP (inner, 0)) == SYMBOL_REF)
       if (GET_CODE (XEXP (inner, 1)) == SYMBOL_REF)
          {
             const char *sym_name = XSTR (XEXP (inner, 1), 0);
             if (! strcmp (sym_name, "<pic base>"))
               return 1;
        }
   }

這裏寫圖片描述

④ 執行 make
⑤ 執行 make install

其他

感謝10年前 Andrew Pinski 幫我解決這麼奇葩的問題 Q A Q

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章