Skip to content

MPICH Adds C flag to CXX Downstream (CMake) #80465

@ax3l

Description

@ax3l

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

N/A

Running this nightly on an Azure Pipeline:

- job: macOS_mpich
  displayName: macOS w/ MPICH
  pool:
    vmImage: macOS-10.15
  steps:
  - script: |
      brew update || true
      brew install mpich
      export MPI_HOME=/usr/local
      # CMake build as below

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

What were you trying to do (and why)?

@iMichka I am tracking down a downstream issue building a C++ CMake project using FindMPI.cmake against Brew's MPICH on macOS-10.15.

What happened (include all command output)?

Since the update in #73062, it looks like this line's -fgnu89-inline for some reason ends on the downstream compiler C++ line ending in a:

[  3%] Building CXX object CMakeFiles/<project>.dir/src/<file>.cpp.o
  clang: warning: -framework -std=c++14: 'linker' input unused [-Wunused-command-line-argument]
  error: invalid argument '-fgnu89-inline' not allowed with 'C++'

What did you expect to happen?

I build this setup nightly and before it compiled.

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

brew install cmake  # 3.20.4
brew install mpich  # 3.4.2

CMakeLists.txt:

cmake_minimum_required(VERSION 3.15.0)
project(BrewMPICH)

find_package(MPI REQUIRED)

add_executable(hello main.cxx)

target_link_libraries(hello PUBLIC MPI::MPI_C MPI::MPI_CXX)

main.cxx:

#include <mpi.h>
#include <iostream>

int main(int argc, char** argv) {
    MPI_Init(NULL, NULL);

    int world_size, world_rank;
    MPI_Comm_size(MPI_COMM_WORLD, &world_size);
    MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);

    std::cout << "Hello world from rank "
        << world_rank << " out of " << world_size << " ranks\n";

    MPI_Finalize();
}
$ cmake -S . -B build -DCMAKE_VERBOSE_MAKEFILE=ON
# ...
  -- Check for working C compiler: /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc - skipped
# ...
  -- Check for working CXX compiler: /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ - skipped
# ...
  -- Found MPI_C: /usr/local/Cellar/mpich/3.4.2/lib/libmpi.dylib (found version "3.1")
  -- Found MPI_CXX: /usr/local/Cellar/mpich/3.4.2/lib/libmpicxx.dylib (found version "3.1")
  -- Found MPI: TRUE (found version "3.1")
# ...

$ cmake --build build
# build issue above

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugReproducible Homebrew/homebrew-core bugoutdatedPR was locked due to age

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions