Bug 1821728

Summary: mpich doesn't work with clang
Product: [Fedora] Fedora Reporter: david08741
Component: mpichAssignee: Zbigniew Jędrzejewski-Szmek <zbyszek>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 33CC: dakingun, peter.georg, zbyszek
Target Milestone: ---   
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: mpich-3.3.2-7.fc33 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-09-15 14:14:29 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

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.