LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   Default/Undefined CFLAGS? (https://www.linuxquestions.org/questions/slackware-14/default-undefined-cflags-300424/)

jong357 03-11-2005 10:43 AM

Default/Undefined CFLAGS?
 
Let's say I built something from source but had no CFLAGS defined globally. What would the resulting binaries be? They would have been compiled on an i686 cpu more than likely but no -march, -mtune or -mcpu options are defined anywhere. Will gcc automatically default to i386 or would it somehow be a 'noarch' even tho binaries are involved?

Thanks!

keefaz 03-11-2005 11:09 AM

gcc -v
cat /usr/lib/gcc-lib/i486-slackware-linux/3.3.5/specs

jong357 03-11-2005 11:29 AM

Ummm..... O.k... So, what would the binaries be?
cating the spec file spits out jibberish beyond reason.

[root@darkstar /work] gcc -v
Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.1/specs
Configured with: ../gcc-3.4.1/configure --prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
Thread model: posix
gcc version 3.4.1

keefaz 03-11-2005 12:03 PM

It's not well documented, but I am pretty sure that you can add your own compile default
flags in the specs file.

If no -march or -mcpu flags are given to gcc I would think your gcc version default it to i686 as
from your output ' i686-pc-linux-gnu '

Did you compile your gcc package, as the output from the slackware gcc is slightly different

keefaz@darkstar:~$ gcc -v
Reading specs from /usr/lib/gcc-lib/i486-slackware-linux/3.3.5/specs
Configured with: ../gcc-3.3.5/configure --prefix=/usr --enable-shared --enable-threads=posix --enable-__cxa_atexit --disable-checking --with-gnu-ld --verbose --target=i486-slackware-linux --host=i486-slackware-linux
Thread model: posix
gcc version 3.3.5

jong357 03-11-2005 12:57 PM

I did compile it myself. Running a Slack/Arch hybrid at the moment. This is more of a curiosity than anything. I set a global CFLAGS and CXXFLAGS of -march=i686 -pipe -O2 but I was really curious what gcc will do on it's own if no CFLAGS are defined globally or in any given Makefile. You would think that the resulting binary should still run on an i386 arch if you didn't tell it to optimize for any given arch. It should pick the lowest common denominator... Thats just my guess anyway...

Anyone know how to test a binary file to see what arch it will run on?

keefaz 03-11-2005 01:15 PM

I would think it is hard to figure out, the commands :

file /path/to/your/program
-->will just report the architecture and some stuff

strings /path/to/your/program
-->will output all strings found in the program (compiler and linker path, version, and more...)

Other than that a good assembly knowledge is required if you want to find which
with flags the program was compiled by dissassemble it and even in this case I would think
you won't find all flags infos

jong357 03-11-2005 01:59 PM

Interesting... Well, thanks. I let this one snow ball in my mind. I suppose it doesn't really matter tho I'd still like to know. It may be one of the unexplained mysteries of the universe... :scratch:


All times are GMT -5. The time now is 11:45 PM.