Skip to content

Cflags in openblas.pc are not compatible with Apple Clang #209091

@dimpase

Description

@dimpase

brew gist-logs <formula> link OR brew config AND brew doctor output

HOMEBREW_VERSION: >=4.3.0 (shallow or no git repository)
ORIGIN: (none)
HEAD: (none)
Last commit: never
Branch: (none)
Core tap JSON: 01 Nov 13:19 UTC
Core cask tap JSON: 01 Feb 22:25 UTC
HOMEBREW_PREFIX: /opt/homebrew
HOMEBREW_CASK_OPTS: []
HOMEBREW_MAKE_JOBS: 10
Homebrew Ruby: 3.3.7 => /opt/homebrew/Library/Homebrew/vendor/portable-ruby/3.3.7/bin/ruby
CPU: deca-core 64-bit arm_firestorm_icestorm
Clang: 16.0.0 build 1600
Git: 2.39.5 => /Library/Developer/CommandLineTools/usr/bin/git
Curl: 8.7.1 => /usr/bin/curl
macOS: 15.3.1-arm64
CLT: 16.2.0.0.1.1733547573
Xcode: 16.1
Rosetta 2: false

(I'm not root on the machine, so I can't meaningfully run brew doctor)
I asked a root for the output of brew gist-logs openblas, still waiting.

EDIT: the root replied with

% brew gist-logs openblas
> Error: No logs.

Verification

  • My brew doctor output says Your system is ready to brew. and am still able to reproduce my issue.
  • I ran brew update and am still able to reproduce my issue.
  • I have resolved all warnings from brew doctor and that did not fix my problem.
  • I searched for recent similar issues at https://github.com/Homebrew/homebrew-core/issues?q=is%3Aissue and found no duplicates.

What were you trying to do (and why)?

I am trying to use Homebrew's openblas with XCode C compiler, Apple's clang:

Apple clang version 16.0.0 (clang-1600.0.26.6)
Target: arm64-apple-darwin24.3.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin

Openblas is located in /opt/homebrew/Cellar/openblas/0.3.29/ and its openblas.pc produces the following CFLAGS:

% PKG_CONFIG_PATH="/opt/homebrew/Cellar/openblas/0.3.29/lib/pkgconfig"  pkg-config -cflags openblas 
-I/opt/homebrew/Cellar/openblas/0.3.29/include -fopenmp

Such flags are not accepted by Apple's clang.
Specifically, on gets:

% clang -c foobar.c -fopenmp
   clang: error: unsupported option '-fopenmp'

The correct format for the OpenMP option is -Xclang -fopenmp,
as can be checked directly, or read on the R Project website: https://mac.r-project.org/openmp/

Thus, openblas.pc has to be fixed, but it's probably only opening a can of worms, as I have no idea whether
libgomp, against which libopenblas is linked, is not compatible with Apple clang's support of OpenMP.

What happened (include all command output)?

% export PKG_CONFIG_PATH="/opt/homebrew/Cellar/openblas/0.3.29/lib/pkgconfig"
% clang -c foobar.c  `pkg-config -cflags openblas`

      clang: error: unsupported option '-fopenmp'

What did you expect to happen?

It should work.

Step-by-step reproduction instructions (by running brew commands)

let `foobar.c` contain valid C code.

brew install openblas
export PKG_CONFIG_PATH=<path to libopenblas.dylib location>/pkgconfig
clang -c foobar.c  `pkg-config -cflags openblas`


One needs a recent XCode on arm64 (I tested on M1, other people tell me that on M4 it's the same).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions