Bug 1821728 - mpich doesn't work with clang
Summary: mpich doesn't work with clang
Keywords:
Status: CLOSED RAWHIDE
Alias: None
Product: Fedora
Classification: Fedora
Component: mpich
Version: 33
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Zbigniew Jędrzejewski-Szmek
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-04-07 13:27 UTC by david08741
Modified: 2020-09-15 14:14 UTC (History)
3 users (show)

Fixed In Version: mpich-3.3.2-7.fc33
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed: 2020-09-15 14:14:29 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)

Description david08741 2020-04-07 13:27:52 UTC
Description of problem:
mpich injects various flags which prevents clang from compiling.

This prevents using mpich from projects that require clang, as well as 

Version-Release number of selected component (if applicable):
rawhide to f30

How reproducible:
always

Steps to Reproduce:
0. module load mpi/mpich-x86_64
1. export MPICH_CC=clang
2. mpicc test.c

Actual results:
clang-10: error: unknown argument: '-fstack-clash-protection'

Expected results:
a.out is created

Additional info:
Related to #1795674

This works fine with openmpi

Comment 1 Peter Georg 2020-06-03 15:21:52 UTC
Any progress on this issue? It not only blocks clang from being used as a compiler for MPICH's mpicc or mpicxx, but also results in unexpected behavior for any compiler.

The manpage for mpicc says in its description:
"""
       This command can be used to compile and link MPI programs written in C.  It
       provides the options and any special libraries that are needed  to  compile
       and link MPI programs.

       It is important to use this command, particularly when linking programs, as
       it provides the necessary libraries.
"""

I.e. when simply compiling a single source file with mpicc source.c I expect it to be compiled with all options required and the necessary libraries, but no other particular options. With the current setup it will automatically turn on -g, -O2, -Wall, and even treats at least one warning as an error (-Werror=format-security). These options are in no way "needed to compile and link MPI programs", it might even cause my code to not compile anymore. Or cause other compilers than gcc to not work with mpicc / mpicxx.

According to the MPICH 3.3 Readme (https://www.mpich.org/static/downloads/3.3/mpich-3.3-README.txt) the output of mpicc -compile_info / -link_info depends on the following:
"""
3. Compiler Flags
=================

MPICH allows several sets of compiler flags to be used. The first
three sets are configure-time options for MPICH, while the fourth is
only relevant when compiling applications with mpicc and friends.

(a) CFLAGS, CPPFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS and LIBS
(abbreviated as xFLAGS): Setting these flags would result in the
MPICH library being compiled/linked with these flags and the flags
internally being used in mpicc and friends.

(b) MPICHLIB_CFLAGS, MPICHLIB_CPPFLAGS, MPICHLIB_CXXFLAGS,
MPICHLIB_FFLAGS, and MPICHLIB_FCFLAGS (abbreviated as
MPICHLIB_xFLAGS): Setting these flags would result in the MPICH
library being compiled with these flags.  However, these flags will
*not* be used by mpicc and friends.

(c) MPICH_MPICC_CFLAGS, MPICH_MPICC_CPPFLAGS, MPICH_MPICC_LDFLAGS,
MPICH_MPICC_LIBS, and so on for MPICXX, MPIF77 and MPIFORT
(abbreviated as MPICH_MPIX_FLAGS): These flags do *not* affect the
compilation of the MPICH library itself, but will be internally used
by mpicc and friends.


  +--------------------------------------------------------------------+
  |                    |                      |                        |
  |                    |    MPICH library     |    mpicc and friends   |
  |                    |                      |                        |
  +--------------------+----------------------+------------------------+
  |                    |                      |                        |
  |     xFLAGS         |         Yes          |           Yes          |
  |                    |                      |                        |
  +--------------------+----------------------+------------------------+
  |                    |                      |                        |
  |  MPICHLIB_xFLAGS   |         Yes          |           No           |
  |                    |                      |                        |
  +--------------------+----------------------+------------------------+
  |                    |                      |                        |
  | MPICH_MPIX_FLAGS   |         No           |           Yes          |
  |                    |                      |                        |
  +--------------------+----------------------+------------------------+


All these flags can be set as part of configure command or through
environment variables.
"""

The current mpich.spec file (https://src.fedoraproject.org/rpms/mpich/blob/master/f/mpich.spec) uses the %configure rpm macro, hence sets the xFLAGS.
For the reasons given above it should be changed to only set the MPICHLIB_xFLAGS. RPM opt flags *should* only be used to compile MPICH and not force everyone to use them.

Fedora (and CentOS, RHEL) are the only systems I have seen so far configuring MPICH like this.

Without this change the mpicc / mpicxx wrapper seem to be useless to me (apart from being used to build other packages).

Comment 2 Ben Cotton 2020-08-11 13:16:48 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 33 development cycle.
Changing version to 33.

Comment 3 Zbigniew Jędrzejewski-Szmek 2020-09-15 14:14:29 UTC
Should be fixed now.


Note You need to log in before you can comment on or make changes to this bug.