Gcc unknown linux gnu

Obtaining current GCC architecture

How can I find out what the -march default argument is for the current architecture if I don’t supply any?

5 Answers 5

gcc -dumpmachine gives you the target triplet, e.g. x86_64-unknown-linux-gnu

If gcc -v shows GCC was configured with a —with-arch option (or —with-arch-32 and/or —with-arch-64 ) then that’s what will be the default.

Without a —with-arch option (and if there isn’t a custom specs file in use) then the arch used will be the default for the target.

For x86, up to and including GCC 4.4, the default for 32-bit was -march=i386 and for 64-bit was -march=x86-64 (note the hyphen instead of underscore.)

For x86 with GCC 4.5 and later versions the default arch is inferred from the target triplet i.e. configuring for i586-pc-linux-gnu means the default is -march=i586 , configuring for core2-pc-linux-gnu means the default is -march=core2 .

Some other platforms also infer the default arch from the target triplet (and have done since before GCC 4.4) so e.g. ultrasparc2-sun-solaris2.10 implies -march=ultrasparc2 .

The gcc -dumpmachine options is perfect. Another example of how a two second search on stackoverflow avoids another read of the gcc man page!

I have read the manual, and enjoyed it. What I meant was that you can search stackoverflow with more human search terms rather than going through the man page. For example, I have used gcc -dumpmachine before but couldn’t remember the argument name. However I can’t do a easy search in the man page for the correct argument sometimes. Maybe I should change «avoids another read of» to «avoids another search through» 😉

Ah yes, fair enough, that’s certainly easier than remembering the exact term to search for in the manual, because if you could remember it you wouldn’t need to look it up!

The only problem is that MinGW says just mingw32 and I don’t see any option to find whether it means i386 or i486 or i686 or what (unlike cygwin gcc for mingw, which says i686-pc-mingw).

The specs file can also modify what particular tuning flags are used. So beware of that. Effectively the trick with echo | gcc -v -E — 2>&1 | grep cc1 shown in another answer will reveal what the specs file is using.

I found this gem on the GCC mailing list that prints the default -march and mtune parameters:

$ echo | gcc -v -E - 2>&1 | grep cc1 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.9.0/cc1 -E -quiet -v - -mtune=generic -march=x86-64 

Basically, you are compiling an empty file from stdin and while doing so, you print the commands.

Читайте также:  Linux file server ubuntu server

Makes sense to point out that -m32 and -m64 can be used on the gcc invocation to ask for either 32-bit or 64-bit (default) targets.

You can use gcc -Q —help= to list the current option values of the given . Thus:

$ gcc -Q --help=target | grep march -march= x86-64 $ gcc -m32 -Q --help=target | grep march -march= i686 $ i686-w64-mingw32-gcc -Q --help=target | grep march -march= pentiumpro 

Edit: Actually, this option is not as generally useful as it appears, because target-specific defaults are not reflected in the output.

will show something like this:

COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/src/gcc-4.7.1/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --enable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release Thread model: posix gcc versie 4.7.1 (GCC) 

The Target: line is what you want. You should be able to deduce enough information from this.

Источник

Why gcc show `unknown` in Target: x86_64-unknown-linux-gnu in Arch Linux?

I would like to know why when I run gcc -v under Arch Linux, it shows the unknown word in these outputs:

Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/5.1.0/lto-wrapper Target: x86_64-unknown-linux-gnu 
 Using built-in specs. COLLECT_GCC=gcc COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-ubuntu-linux-gnu/5.1.0/lto-wrapper Target: x86_64-ubuntu-linux-gnu 

2 Answers 2

As it was already mentioned in the comment, by default the target triplet is generated by config.guess script. It’s logic is fairly simple. First it uses uname to get some basic system information:

UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown 

These strings are combined and matched against hardcoded patterns. The result is also hardcoded:

case "$:$:$:$" in . (snip). x86_64:Linux:*:*) echo $-unknown-linux-$ . (snip). 

For some systems it is possible to give more meaningful result, like IBM in «rs6000-ibm-aix».

Distribution maintainers simply override this string with their own (also hardcoded):

$ gcc -v . (snip). Target: x86_64-linux-gnu Configured with: ../src/configure -v --with-pkgversion='Debian 4.9.2-10' . (snip). --target=x86_64-linux-gnu 

GCC 6 will probably output x86_64-pc-linux-gnu by default: updated config.guess in the upstream repository.

Источник

Preface & Content

You want to have a GCC toolchain to compile C/C++ programs for Linux, while you work on your Windows machine? You already use Cygwin on Windows and have Windows 7 / 8 or Windows 10 and do not want to use a slow Virtual Machine?

  • Then you could either switch to use Windows Subsystem for Linux on Windows 10, which provides a more modern alternative provided by Microsoft. Just search for «Ubuntu» or the name of your favourite Linux distribution in the Microsoft Store and click on install.
  • Or you can follow this tutorial to build a GCC Cross-Compiler in Cygwin if you don’t want to or can’t switch to WSL.
  • Installation of Cygwin and needed tools
  • Building of crosstool-ng
  • Allowing a case sensitive file system
  • Building the target toolchain
  • Creating a tarball
  • Installation of the toolchain
  • Testing the toolchain
  • Files
Читайте также:  Kali linux realtek wifi

Cygwin tool installation

Download the cygwin installer setup-x86_64.exe from cygwin.com. The crosstool-ng build will need some utilities to succeed. Install the following packages via the graphical installer or use the command line below.

  • tar
  • wget
  • gcc-core
  • gcc-g++
  • binutils
  • make
  • cmake
  • automake
  • autoconf
  • git
  • patch
  • unzip
  • flex
  • bison
  • gperf
  • help2man
  • libtool
  • gettext
  • libgmp10
  • libgmp-devel
  • libmpfr6
  • libmpfr-devel
  • libmpc3
  • libmpc-devel
  • libncurses-devel
  • libintl-devel
setup-x86_64.exe -a x86_64 -d -q -P "tar,wget,gcc-core,gcc-g++,binutils,make,cmake,automake,autoconf,git,patch,unzip,flex,bison,gperf,help2man,libtool,gettext,libgmp10,libgmp-devel,libmpfr6,libmpfr-devel,libmpc3,libmpc-devel,libncurses-devel,libintl-devel"

Building crosstool-ng

Open a bash prompt — named ‘Cygwin64 Terminal’ in the start menu — and execute the following steps. This should build and install crosstools-ng from source and allows the build of recent gcc versions. A benefit of using crosstool-ng is the support for parallel compilation of the target toolchain. This results in an optimal CPU usage of 100% during compilation.

Allowing a case-sensitive file system

Execute the follwing script with a bash prompt (Cygwin64 Terminal) as Administrator (Right-click the shortcut in the start menu. Then select «Run as Administrator»). This configures the Windows file system to allow case-sensitive filenames. You can read more here.

Reboot your PC after this step!
reg ADD "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\Kernel" /v obcaseinsensitive /t REG_DWORD /d 0 /f
Bug

Activating the case-sensitivity may break WSL!

Building the toolchain

Start the configuration with the following code snipped. This will create a new directory named compile-cs on your C-drive and mount this folder as case-sensitive file system under /usr/compile. You will need administrator rights on your PC to create a folder directly on your root of the hard drive. So adjust the source path as desired.

The next step is to configure the created toolchain.

Select the following under Path and misc options:

  • Local Tarballs: /usr/compile/src
  • Work Directory: /usr/compile/.build
  • Prefix Directory: /usr/compile/x-tools/$

Select under Operating System:

Activate C++ Support under C compiler:

Select the Target options as desired:

x86_64-unknown-linux-gnu

powerpc64-unknown-linux-gnu

  • Architecture: powerpc
  • Architecture Bitness: 64
  • Compile libssp: Yes
  • Compile libsanitizer: yes

Save the configuration and start the build with the following command:

This will take some time. So be prepared to do something else meanwhile.

Creating a tarball

Execute the following script via bash prompt (Cygwin64 Terminal) to create a final archive. This will contain the complete toolchain including system libraries (libc, libcxx) and linux headers.

Читайте также:  Совместимость операционных систем linux

Installing the toolchain

Add the folder /usr/local/$/bin to your path environment variable (Replace $ with the toolchain-name).

Testing the toolchain

Download the gcc-test.zip archive and run make main_i686 or make main_x86_64. This will build both test applications below via make (c and c++ version) and analyze the generated files.

The respective .txt file contains the generated signature and import table of each application. The content should be similar to the displayed below. You will need a linux machine to run the generated binary files. This can be accomplished with a virtual machine.

Files

gcc 10.2.0 for cygwin64 3.1.7

  • MEGA (fast): x86_64-unknown-linux-gnu-10.2.0.tar.gzDirect (slow): x86_64-unknown-linux-gnu-10.2.0.tar.gz CRC32: 1E2F522D
    MD5: 9A65DB473B74640846703EEDE0452F2D
    SHA-1: 5116FD2CEC0D22EFCE6E2974BC6A216C60E69258
  • MEGA (fast): i686-unknown-linux-gnu-10.2.0.tar.gzDirect (slow): i686-unknown-linux-gnu-10.2.0.tar.gz CRC32: A47ACD7F
    MD5: D04CE11D701BADC5473257376E9EC78E
    SHA-1: 8E95FF3A74A65F03D7ADD571B59ED2EADCEBC52E
  • MEGA (fast): powerpc64-unknown-linux-gnu-10.2.0.tar.gzDirect (slow): powerpc64-unknown-linux-gnu-10.2.0.tar.gz CRC32: EB17E80A
    MD5: 7EB210193F5D138225C3EFB66D855582
    SHA-1: 7FA2CA109A54FF23452B97861B85371A1F3E4B10

gcc 9.2.0 for cygwin64 3.0.7

  • MEGA (fast): x86_64-unknown-linux-gnu-9.2.0.tar.gzDirect (slow): x86_64-unknown-linux-gnu-9.2.0.tar.gz CRC32: DAFB720E
    MD5: BCB53C0ED67F4BAE62853085DAE9619C
    SHA-1: 748582624CD9F966967DDFE12F0D68EA03D82BD2
  • MEGA (fast): i686-unknown-linux-gnu-9.2.0.tar.gzDirect (slow): i686-unknown-linux-gnu-9.2.0.tar.gz CRC32: 8CBA67BE
    MD5: 53FBE54F911C695758126968BB8CF640
    SHA-1: AC983963036957B420F763FC03CCF670EDCF66EE

gcc 7.2.0 for cygwin64 2.9.0

  • MEGA (fast): x86_64-unknown-linux-gnu-7.2.0.tar.gzDirect (slow): x86_64-unknown-linux-gnu-7.2.0.tar.gz CRC32: 7B60472F
    MD5: 1385EEB518EC8B72DEA63BFB27D6451C
    SHA-1: 6F8BC037B74F904EE36752AEF75239F525A37218
  • MEGA (fast): i686-unknown-linux-gnu-7.2.0.tar.gzDirect (slow): i686-unknown-linux-gnu-7.2.0.tar.gz CRC32: C0AAEF50
    MD5: 0E8539E0C63854A0EB6827F4F3917C78
    SHA-1: 613C3B8E7E6A95887F46F765673DC9641774D36B

(Un-)License

See https://www.gnu.org/ and https://github.com/crosstool-ng/crosstool-ng for the applying licenses regarding the used software.

Regarding the used scripts / code on this page:

This is free and unencumbered software released into the public domain.

Anyone is free to copy, modify, publish, use, compile, sell, or distribute this software, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means.

In jurisdictions that recognize copyright laws, the author or authors of this software dedicate any and all copyright interest in the software to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this software under copyright law.

THE SOFTWARE IS PROVIDED «AS IS», WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Источник

Оцените статью
Adblock
detector