Skip to content

-Xclang -fopenmp errors with UnknownFlag. #2522

@ahoereth

Description

@ahoereth

Getting Can't handle UnknownFlag arguments with -Xclang when using OpenMP from brew through find_package(OpenMP REQUIRED) on macOS 14.8.3.

Expected sccache behavior:

  • First compilation: Cache miss (expected)
  • Second compilation: Cache hit (expected, but fails due to -Xclang flag)

Actual sccache behavior:

  • Can't handle UnknownFlag arguments with -Xclang

To reproduce install brew install libomp, then run the "not working" command below. To easily verify the error run sccache --zero-stats before and sccache --show-stats after execution.

Not working:

sccache clang++ -Xclang -fopenmp -I/opt/homebrew/include -L/opt/homebrew/lib -lomp sccache_openmp.cpp -o sccache_openmp

Replacing -Xclang with -Xpreprocessor works around the problem:

sccache clang++ -Xpreprocessor -fopenmp -I/opt/homebrew/include -L/opt/homebrew/lib -lomp sccache_openmp.cpp -o sccache_openmp

sccache_openmp.cpp:

#include <iostream>
#include <omp.h>

int main() {
#pragma omp parallel
  {
    int thread_id   = omp_get_thread_num();
    int num_threads = omp_get_num_threads();

#pragma omp critical
    {
      std::cout << "Thread " << thread_id << " of " << num_threads << " threads"
                << std::endl;
    }
  }

  return 0;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions