Unavailable option on Apple clang only; version mismatch?

I want to use clang's option -ffile-prefix-map. This option is normally available since Clang 10.

Indeed, if I get a Docker image with clang (e.g. docker pull silkeh/clang:10), I can run it without any problems:

clang -ffile-prefix-map=a=b

However, the same command in my macOS 10.15.7 results in error: unknown argument: '-ffile-prefix-map=a=b'. If I run clang --version, I get:

Apple clang version 11.0.0 (clang-1100.0.33.17)
Target: x86_64-apple-darwin19.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

This seems to suggest I have Clang 11, which should have the option.

Is this a quirk in Apple's Clang, or am I misreading its version? Is there some table showing matching versions between both Clangs, which would explain the error?


Solution 1:

This is indeed a difference between LLVM clang https://github.com/llvm/llvm-project and Apple Clang https://github.com/apple/llvm-project/ .

Apple Clang 12+ supports this flag IIRC.

To check if a flag is supported, you can write a C file with an empty main function and compile it with the flag of interest, and -Wno-error. If it exits with non zero status, the flag is not supported.