溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

gcc編譯選項

發布時間:2020-09-06 16:09:36 來源:網絡 閱讀:1890 作者:清風徐來918 欄目:開發技術


(1)fpic 和 fPIC 區別

在64位下編譯動態庫的時候,經常會遇到下面的錯誤

/usr/bin/ld: /tmp/ccQ1dkqh.o: relocation R_X86_64_32 against `a local symbol' can not be used when making a shared object; recompile with -fPIC


Use -fPIC or -fpic to generate code. Whether to use -fPIC or -fpic to generate code is target-dependent. The -fPIC choice always works, but may produce larger code than -fpic (mnenomic to remember this is that PIC is in a larger case, so it may produce larger amounts of code). Using -fpic option usually generates smaller and faster code, but will have platform-dependent limitations, such as the number of globally visible symbols or the size of the code. The linker will tell you whether it fits when you create the shared library. When in doubt, I choose -fPIC, because it always works.


-fPIC: 總是能夠工作,但可能產生的代碼較大

-fpic: 通常能產生更快更小的代碼,但有平臺限制。



(2)編譯選項 -static 的作用

gcc編譯選項gcc編譯選項



(3)-march 指定目標架構選項

-march選項就是就是指定目標架構的名字,gcc就會生成針對目標架構優化的目標代碼,如-march=prescott會生成針對i5或i7的目標碼,從而充分發揮cpu的性能。

自gcc4.2,引入了 -march=native ,從而允許編譯器自動探測目標架構并生成 針對目標架構優化的目標代碼 ,這比手工設置要安全的多。

通過下面的命令查詢當前機器的架構名稱,比如:


#gcc -march=native -Q --help=target | grep march

 -march=                     haswell


有的時候編譯會報 "no such instruction", (沒有這個機器指令)

解決的方案:

1.makefile 中刪掉 -march=native

2.找到正確的目標框架名稱設置


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女