Intel C compiler and binutils

Intel C compiler and binutils

Hello, All!

I am sorry if this is not the right place for this but probably somebody will find this useful.

As far as I understand, Intel C compiler 17.0.2 uses 'cpp' and 'as' when processing assembly files (.S). It's possible that they reside in different directories: /path/to/gcc/bin and /path/to/binutils/bin. If we want to use that specific 'cpp' and that specific 'as' we can just add them to PATH before compiling. Unfortunately, it's not very good to modify PATH variable for my workflow in particular. So, I tried to use icc's command line flags:
icc -gnu-prefix=/path/to/binutils/bin/ file.S

and got the following error:
icc: error #10001: could not find directory in which /path/to/binutils/bin/g++ resides

Fair enough but shouldn't it complain about gcc? I even created a symlink to g++ in that directory and still got the same error. Looks like a bug to me.

Ok, let's give icc the right path to the gcc that want to use:
icc -gcc-name=/path/to/gcc/bin/gcc -gnu-prefix=/path/to/binutils/bin/ file.S

and the error is:
/path/to/binutils/bin/cpp: No such file or directory

Looks like we can't tell icc what we want using just command line arguments. Let's try to set GCC_EXEC_PREFIX, which icc takes into account when looking for 'as' and 'ld':

export GCC_EXEC_PREFIX=/path/to/binutils/bin/
icc -gcc-name=/path/to/gcc/bin/gcc file.S

It worked but I still wish icc used the cpp from /path/to/gcc/bin/ for preprocessing, but not the one it finds in the PATH. Maybe there are ways to get what I want without modifying PATH but I have not found them yet.

However, it would be really nice to be able to specify all necessary paths to applications with just command line arguments. Unfortunately, it looks like icc doesn't currently allow that.

It would also be nice if icc accounted for '--with-as' and '--with-ld' configuration flags of gcc, which hardcode the paths to 'as' and 'ld'. The better solution might be to call 'gcc - print-prog-name=as' but that would require additional calls to gcc while the configuration flags are parsed by icc anyway. On the other hand, this feature would probably introduce additional confusion sometimes.

 

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Sergey,

Thank you for providing the detailed information.

I ran into a similar problem with cpp. I'm passing `-gcc-name=core-gcc` and `-gxx-name=core-g++`, but I have to symlink `core-cpp` to `cpp` and put it in the path.

It seems like there should be a `-cpp-name` option to go with `-gcc-name` and `-gxx-name`.

I don't see why you would want these additional options, unless you have a reason for making icc use a different pre-processor than gcc.  Also, gcc and g++ are designed to have the same version of both active, so it looks bad to try to allow those to differ.

My understanding is that icc doesn't use as unless you request it specifically (as when you supply asm code).

Best Reply

Use the Qlocation option to specify this information,

-Qlocation,as,<dir>  // assembler location

-Qlocation,cpp,<dir>  // preprocessor location

The option is documented here, https://software.intel.com/en-us/cpp-compiler-18.0-developer-guide-and-r...

 

>>Unfortunately, it's not very good to modify PATH variable for my workflow in particular

Why not start a new (nested) bash shell?

(https://stackoverflow.com/questions/7120426/invoke-bash-run-commands-inside-new-shell-then-give-control-back-to-user)

# Create a temporary file
TMPFILE=$(mktemp)

# Add stuff to the temporary file
echo "source ~/.bashrc" > $TMPFILE
echo "<other commands>" >> $TMPFILE
echo "rm -f $TMPFILE" >> $TMPFILE

# Start the new bash shell 
bash --rcfile $TMPFILE

Where <other commands> would contain the PATH concatenation (your new paths first), then the compile command lines

There are additional methods listed in the above link.

Jim Dempsey

Leave a Comment

Please sign in to add a comment. Not a member? Join today