Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

Intel C compiler and binutils

Kosukhin__Sergey
Beginner
789 Views

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.

 

0 Kudos
1 Solution
Melanie_B_Intel
Employee
789 Views

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-reference-qlocation

 

View solution in original post

0 Kudos
5 Replies
gaston-hillar
Valued Contributor I
789 Views

Sergey,

Thank you for providing the detailed information.

0 Kudos
Nolta__Mike
Beginner
789 Views

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`.

0 Kudos
TimP
Honored Contributor III
789 Views

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).

0 Kudos
Melanie_B_Intel
Employee
790 Views

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-reference-qlocation

 

0 Kudos
jimdempseyatthecove
Honored Contributor III
789 Views

>>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

0 Kudos
Reply