Bug 7556 - ccache misinterprets -o and -x options for Intel compiler and Sun Studio
ccache misinterprets -o and -x options for Intel compiler and Sun Studio
Product: ccache
Classification: Unclassified
Component: ccache
x64 Linux
: P3 enhancement
: ---
Assigned To: Joel Rosdahl
Joel Rosdahl
Depends on:
  Show dependency treegraph
Reported: 2010-07-06 02:47 UTC by Thimo Neubauer
Modified: 2016-06-09 19:37 UTC (History)
2 users (show)

See Also:

Trivial OpenMP program (116 bytes, text/x-c++src)
2010-07-06 02:47 UTC, Thimo Neubauer
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Thimo Neubauer 2010-07-06 02:47:18 UTC
To reproduce take a simple program with OpenMP pragmas and run the normal compiler and the same with ccache:

mutabor++ /tmp> icpc -c -openmp foo.cc
mutabor++ /tmp> ccache icpc -c -openmp foo.cc
foo.cc(6): warning #161: unrecognized #pragma
  #pragma omp for

The CCACHE_LOGFILE shows me this:

[2010-07-06T09:35:06.852541 20077] === CCACHE STARTED =========================================
[2010-07-06T09:35:06.852930 20077] Hostname: mutabor
[2010-07-06T09:35:06.852949 20077] Working directory: /tmp
[2010-07-06T09:35:06.852982 20077] Source file: foo.cc
[2010-07-06T09:35:06.852996 20077] Object file: penmp
[2010-07-06T09:35:06.853022 20077] Trying direct lookup
[2010-07-06T09:35:06.853142 20077] Looking for object file hash in /home/thimo/.ccache/b/0/dc6c6b50f00550a95a1657fa8a0f66-233.manifest
[2010-07-06T09:35:06.853169 20077] Did not find object file hash in manifest
[2010-07-06T09:35:06.853184 20077] Running preprocessor
[2010-07-06T09:35:06.853211 20077] Executing /opt/intel/Compiler/11.1/072/bin/intel64/icpc -c -E foo.cc
[2010-07-06T09:35:06.879860 20077] Got object file hash from preprocessor
[2010-07-06T09:35:06.880028 20077] Object file /home/thimo/.ccache/8/c/25129d6edc2c587ce7f864aae08974-233.o not in cache
[2010-07-06T09:35:06.880054 20077] Running real compiler
[2010-07-06T09:35:06.880069 20077] Executing /opt/intel/Compiler/11.1/072/bin/intel64/icpc -c -o /home/thimo/.ccache/8/c/25129d6edc2c587ce7f864aae08974-233.o.tmp.mutabor.20077 /home/thimo/.ccache/tmp/foo.tmp.mutabor.20077.ii
[2010-07-06T09:35:06.936980 20077] Stored in cache: /home/thimo/.ccache/8/c/25129d6edc2c587ce7f864aae08974-233.stderr
[2010-07-06T09:35:06.937040 20077] Stored in cache: /home/thimo/.ccache/8/c/25129d6edc2c587ce7f864aae08974-233.o
[2010-07-06T09:35:06.937171 20077] Copying /home/thimo/.ccache/8/c/25129d6edc2c587ce7f864aae08974-233.o to penmp (uncompressed)
[2010-07-06T09:35:06.937302 20077] Created penmp from /home/thimo/.ccache/8/c/25129d6edc2c587ce7f864aae08974-233.o
[2010-07-06T09:35:06.937718 20077] Added object file hash to /home/thimo/.ccache/b/0/dc6c6b50f00550a95a1657fa8a0f66-233.manifest

Note the "Object file: penmp": ccache consequently interprets the Intel flag "-openmp" as a "-o" option. The workaround is of course

mutabor++ /tmp> ccache icpc -c --ccache-skip -openmp foo.cc
mutabor++ /tmp>

However I'd like to ask you to include a workaround inside ccache. I've stumbled over several reports where people fell for the same trap...

To make the problem worse Intel decided to start quite some options with the "-o" prefix:

mutabor++ /home/thimo> icpc -help | grep -- '^-o'
-opt-streaming-stores <arg>
-opt-report [n]
-openmp   enable the compiler to generate multi-threaded code based on the
-openmp-lib <ver>
-openmp-link <library>
-openmp-task <arg>
-openmp-threadprivate <ver>
-o <file>
-openmp-lib=legacy       use -openmp-lib=compat
mutabor++ /home/thimo> icpc --version
icpc (ICC) 11.1 20100414
Copyright (C) 1985-2010 Intel Corporation.  All rights reserved.
Comment 1 Thimo Neubauer 2010-07-06 02:47:53 UTC
Created attachment 5828 [details]
Trivial OpenMP program
Comment 2 Thimo Neubauer 2010-07-14 04:55:04 UTC
Unfortunately Intel chose to misuse yet another option character, "-x"... As an example: to switch on SSE opcodes the flag "-xK" or "-xSSE" has to be used. This option (of course) confuses ccache which complains about the unknown language "K" or "SSE". Here's the compiler documentation:

          generate specialized code to run exclusively on processors
          indicated by <code> as described below
            Host generate instructions for the highest instruction set and
                 processor available on the compilation host machine

            SSE2 Intel Pentium 4 and compatible Intel processors.  Enables new
                 optimizations in addition to Intel processor-specific

            SSE3    Intel(R) Core(TM) processor family with Streaming SIMD
                    Extensions 3 (Intel(R) SSE3) instruction support
            SSE3_ATOM Can generate MOVBE instructions for Intel processors and
                    can optimize for the Intel(R) Atom(TM) processor.
            SSSE3   Intel(R) Core(TM)2 processor family with Supplemental
                    Streaming SIMD Extensions 3 (SSSE3)
            SSE4.1  Intel(R) 45nm Hi-k next generation Intel Core(TM)
                    microarchitecture with support for SSE4 Vectorizing
                    Compiler and Media Accelerator instructions

            SSE4.2  Can generate Intel(R) SSE4 Efficient Accelerated String
                    and Text Processing instructions supported by Intel(R)
                    Core(TM) i7 processors. Can generate Intel(R) SSE4 
                    Vectorizing Compiler and Media Accelerator, Intel(R) SSSE3,
                    SSE3, SSE2, and SSE instructions and it can optimize for
                    the Intel(R) Core(TM) processor family.
            AVX     Enable Intel(R) Advanced Vector Extensions instructions

The "one character" version is mentioned in the "deprecated options":

-xB                      use -xSSE2 (i32 only)
-xK                      use -xSSE (i32 only)
-xW                      use -msse2
-xN                      use -xSSE2
-xP                      use -xSSE3
-xT                      use -xSSSE3
-xS                      use -xSSE4.1
-xO                      use -msse3

Fortunately "--ccache-skip" saved me again :)
Comment 3 Joel Rosdahl 2010-07-14 16:30:28 UTC
I think we need to make ccache behave differently for different compilers to fix this; making all these flags work for all compilers will not fly. My proposal is to detect how the compiler reacts to certain flags and then cache the result of those tests. For instance, to detect whether -ox should be considered as an output file option or not can be detected by running something like "cd $CCACHE_DIR/tmp; touch empty.c; compiler -c empty.c -oempty.o".
Comment 4 mehturt 2010-09-14 13:29:31 UTC
Sun Studio is also affected, it uses -xarch, -xtarget and other -x parameters as well.
Comment 5 Paul Wolfenbarger 2014-06-20 21:16:45 UTC
I have been looking at this and we have both -openmp and -xAVX/-xhost in our intel compiles. 

The -x question can be easily had led by ignoring unknown options (basically I just pass them to the compiler) and only sending valid file types downstream.

The -o has been giving me more fits.  I agree that maintaining multiple compiler definitions (even if encapsulated) is likely to be an ongoing maintenance nightmare.  I cannot yet on the other hand find a solid way to distinguish valid output options from spurious ones.

Any ideas are welcome.
Comment 6 Joel Rosdahl 2016-06-09 19:37:01 UTC
Closing this now since no progress has been made for several years. Please create a new issue at https://github.com/ccache/ccache/issues if wanted.