Re: [unable to compile MPICH v4.2.1 with GNU toolchain v13.2.0 @ macOS Sonoma v14.4.1]

2024-05-14 Thread Ryan Schmidt
On May 13, 2024, at 21:35, Ryan Schmidt wrote:
> 
> What I found before said that the problem had been fixed in gcc 11.1. 

It was pointed out in that issue today that newer gcc will still experience the 
problem when in C99 mode. 

https://trac.macports.org/ticket/69632#comment:11




Re: [unable to compile MPICH v4.2.1 with GNU toolchain v13.2.0 @ macOS Sonoma v14.4.1]

2024-05-13 Thread Ryan Schmidt
On May 13, 2024, at 10:07, Maxim Abalenkov wrote:
> 
>> If you want to build anything from source on macOS, use clang unless there 
>> is an extremely good reason to use gcc.
> 
> When you say clang, do you recommend using Apple’s clang or clang from 
> MacPorts?

Whichever you like. Whichever works for you. Apple's clang is convenient 
because it is already installed. If it does not work for you, you can try a 
MacPorts clang. Take care to understand that the MacPorts clang ports are 
versions of llvm.org clang which is different from Apple clang. They have 
different version numbering schemes and sometimes different capabilities. 

> One extremely good reason to use gcc is the ability to have a Fortran 
> compiler. I need an MPICH distribution with Fortran compiler wrappers and 
> Fortran modules.

The MacPorts mpich port offers this via its several sub ports, for example the 
mpich-gcc13 sub port. Yes, this uses gcc13, but in this case it has hopefully 
already been tested and verified to be working by a MacPorts contributor. 


>> You said in the subject line that you're using gcc 13.2.0 but that's not 
>> confirmed by the log. When I researched this error recently, I found that 
>> this bug was fixed in gcc 11.1 which makes me think you are actually trying 
>> to use a gcc version older than that. See 
>> https://trac.macports.org/ticket/69632
> 
> I set gcc to point to mp-gcc13 with a MacPorts command:
> 
> sudo port select --set gcc mp-gcc13

That should work. 

> In my Perl script I ensure FC, CC and CXX environment variables point to 
> compilers in /opt/local/bin/{gcc,g++,gfortran}. Is there any other way to 
> verify that I’m using the right version of GNU compilers?

You can run "gcc --version" to verify. If it says you are indeed running gcc 13 
then I cannot explain the error. What I found before said that the problem had 
been fixed in gcc 11.1. 

Re: [unable to compile MPICH v4.2.1 with GNU toolchain v13.2.0 @ macOS Sonoma v14.4.1]

2024-05-13 Thread Maxim Abalenkov
Hello Ryan et al.,

Thank you for your quick reply.

> If you want to build anything from source on macOS, use clang unless there is 
> an extremely good reason to use gcc.

When you say clang, do you recommend using Apple’s clang or clang from 
MacPorts? One extremely good reason to use gcc is the ability to have a Fortran 
compiler. I need an MPICH distribution with Fortran compiler wrappers and 
Fortran modules.

> You said in the subject line that you're using gcc 13.2.0 but that's not 
> confirmed by the log. When I researched this error recently, I found that 
> this bug was fixed in gcc 11.1 which makes me think you are actually trying 
> to use a gcc version older than that. See 
> https://trac.macports.org/ticket/69632

I set gcc to point to mp-gcc13 with a MacPorts command:

sudo port select --set gcc mp-gcc13

In my Perl script I ensure FC, CC and CXX environment variables point to 
compilers in /opt/local/bin/{gcc,g++,gfortran}. Is there any other way to 
verify that I’m using the right version of GNU compilers?

> In your script the flag -I /opt/local/include/unistring/cdefs.h will not help 
> anything because /opt/local/include/unistring/cdefs.h is not a directory that 
> contains headers.

This was my futile attempt to ‘include’ the correct ‘cdefs.h’ header file, that 
was causing problems. Thank you for your help and have a great day ahead!

—
Best wishes,
Maxim

Maxim Abalenkov \\ maxim.abalen...@gmail.com
+44 7 486 486 505 \\ www.maxim.abalenkov.uk

> On 13 May 2024, at 14:51, Ryan Schmidt  wrote:
> 
> On May 13, 2024, at 05:36, Maxim Abalenkov wrote:
>> 
>> Dear all,
>> 
>> How are you? I hope all is well with you. I need help please. I’m struggling 
>> to compile MPICH v4.2.1 (from source code) with the GNU toolchain v13.2.0 @ 
>> macOS Sonoma v14.4.1. Please see my configuration and installation Perl 
>> script attached. I also attach a full log of the compilation errors. I 
>> recently installed GNU toolchain via MacPorts. When the script proceeds to 
>> compilation, it crashes with the following error messages:
>> 
>> Compiling MPICH...
>> In file included from 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/_types.h:32,
>>  from 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/_types.h:27,
>>  from 
>> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/pthread.h:55,
>>  from ../../../modules/yaksa/src/util/yaksu_atomics.c:6:
>> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/cdefs.h:554:30:
>>  error: missing ')' after "__has_attribute"
>>   554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage)
>>   |  ^
>> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/cdefs.h:554:31:
>>  error:  ':' without preceding '?'
>>   554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage)
>> 
>> I suspect that Apple compilers’ header files are picked up erroneously. Is 
>> this normal for GNU toolchain to rely on Apple SDK’s header files? I’m new 
>> to Apple CPUs. Would you please educate me, what is the suggested way of 
>> installing software on Apple M? processors from source? Or should I just 
>> save the pain and install my code using Apple’s native toolchain? Thank you 
>> for your help and have a productive week ahead!
> 
> If you want to use mpich, the easiest solution is to use MacPorts to install 
> it. 
> 
> If you want to build anything from source on macOS, use clang unless there is 
> an extremely good reason to use gcc. 
> 
> You said in the subject line that you're using gcc 13.2.0 but that's not 
> confirmed by the log. When I researched this error recently, I found that 
> this bug was fixed in gcc 11.1 which makes me think you are actually trying 
> to use a gcc version older than that. See 
> https://trac.macports.org/ticket/69632
> 
> In your script the flag -I /opt/local/include/unistring/cdefs.h will not help 
> anything because /opt/local/include/unistring/cdefs.h is not a directory that 
> contains headers. 



Re: [unable to compile MPICH v4.2.1 with GNU toolchain v13.2.0 @ macOS Sonoma v14.4.1]

2024-05-13 Thread Ryan Schmidt
On May 13, 2024, at 05:36, Maxim Abalenkov wrote:
> 
> Dear all,
> 
> How are you? I hope all is well with you. I need help please. I’m struggling 
> to compile MPICH v4.2.1 (from source code) with the GNU toolchain v13.2.0 @ 
> macOS Sonoma v14.4.1. Please see my configuration and installation Perl 
> script attached. I also attach a full log of the compilation errors. I 
> recently installed GNU toolchain via MacPorts. When the script proceeds to 
> compilation, it crashes with the following error messages:
> 
> Compiling MPICH...
> In file included from 
> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/_types.h:32,
>  from 
> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/_types.h:27,
>  from 
> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/pthread.h:55,
>  from ../../../modules/yaksa/src/util/yaksu_atomics.c:6:
> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/cdefs.h:554:30:
>  error: missing ')' after "__has_attribute"
>   554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage)
>   |  ^
> /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/cdefs.h:554:31:
>  error:  ':' without preceding '?'
>   554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage)
> 
> I suspect that Apple compilers’ header files are picked up erroneously. Is 
> this normal for GNU toolchain to rely on Apple SDK’s header files? I’m new to 
> Apple CPUs. Would you please educate me, what is the suggested way of 
> installing software on Apple M? processors from source? Or should I just save 
> the pain and install my code using Apple’s native toolchain? Thank you for 
> your help and have a productive week ahead!

If you want to use mpich, the easiest solution is to use MacPorts to install 
it. 

If you want to build anything from source on macOS, use clang unless there is 
an extremely good reason to use gcc. 

You said in the subject line that you're using gcc 13.2.0 but that's not 
confirmed by the log. When I researched this error recently, I found that this 
bug was fixed in gcc 11.1 which makes me think you are actually trying to use a 
gcc version older than that. See https://trac.macports.org/ticket/69632

In your script the flag -I /opt/local/include/unistring/cdefs.h will not help 
anything because /opt/local/include/unistring/cdefs.h is not a directory that 
contains headers. 

[unable to compile MPICH v4.2.1 with GNU toolchain v13.2.0 @ macOS Sonoma v14.4.1]

2024-05-13 Thread Maxim Abalenkov
Dear all,How are you? I hope all is well with you. I need help please. I’m struggling to compile MPICH v4.2.1 (from source code) with the GNU toolchain v13.2.0 @ macOS Sonoma v14.4.1. Please see my configuration and installation Perl script attached. I also attach a full log of the compilation errors. I recently installed GNU toolchain via MacPorts. When the script proceeds to compilation, it crashes with the following error messages:Compiling MPICH...In file included from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/_types.h:32,                 from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/_types.h:27,                 from /Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/pthread.h:55,                 from ../../../modules/yaksa/src/util/yaksu_atomics.c:6:/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/cdefs.h:554:30: error: missing ')' after "__has_attribute"  554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage)      |                              ^/Library/Developer/CommandLineTools/SDKs/MacOSX14.sdk/usr/include/sys/cdefs.h:554:31: error:  ':' without preceding '?'  554 | #if __has_cpp_attribute(clang::unsafe_buffer_usage)I suspect that Apple compilers’ header files are picked up erroneously. Is this normal for GNU toolchain to rely on Apple SDK’s header files? I’m new to Apple CPUs. Would you please educate me, what is the suggested way of installing software on Apple M? processors from source? Or should I just save the pain and install my code using Apple’s native toolchain? Thank you for your help and have a productive week ahead!—Best wishes,Maxim#!/usr/bin/env perl

## @brief   Configures, compiles and installs MPICH with GNU compiler toolchain.

## @author  Maksims Abalenkovs
## @email   maksims.abalenk...@stfc.ac.uk
## @dateApr 22, 2023
## @version 0.5

use v5.38.2;
use autodie;
use strict;
use warnings;
use local::lib;
use Cwd qw(getcwd);
use File::Slurper qw(write_text);
use IPC::System::Simple qw(capturex);

my $rootdir   = ();
my $gnubin= '/opt/local/bin';

my $prefix= '/opt/mpich-4.2.1';
my $np= 8;
my $build_dir = 'build';

printf "prefix:%s\n", $prefix;
printf "np:%s\n", $np;
printf "build_dir: %s\n", $build_dir;

print "Setting environment variables...\n";

$ENV{'FC'}  = $gnubin . '/gfortran';
$ENV{'F77'} = $ENV{'FC'};
$ENV{'CC'}  = $gnubin . '/gcc';
$ENV{'CXX'} = $gnubin . '/g++';

$ENV{'FFLAGS'} = '-fPIC -m64 -fallow-argument-mismatch -I /opt/local/include/unistring/cdefs.h';
$ENV{'CFLAGS'} = '-fPIC -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -m64 -I /opt/local/include/unistring/cdefs.h';

print "Environment variables were set to:\n";

printf "  FC:  %s\n",   $ENV{'FC'};
printf "  F77: %s\n",   $ENV{'F77'};
printf "  CC:  %s\n",   $ENV{'CC'};
printf "  CXX: %s\n\n", $ENV{'CXX'};

printf "  FFLAGS: %s\n", $ENV{'FFLAGS'};
printf "  CFLAGS: %s\n", $ENV{'CFLAGS'};

mkdir $build_dir;
chdir $build_dir;

print "Configuring MPICH...\n";
my @conf_options = (
"--prefix=$prefix",
'--enable-shared=no',
'--enable-fast=O3,ndebug',
'--disable-error-checking',
'--enable-fortran=all',
'--enable-cxx',
'--enable-romio' );

my $log = capturex('../configure', @conf_options);
_text('c.txt', $log);

print "Compiling MPICH...\n";
$log = capturex('make', '-j', $np);
_text('m.txt', $log);

print "Installing MPICH into $prefix...\n";
$log = capturex('make', 'install');
_text('mi.log', $log);

print "Checking MPICH installation...\n";
$log = capturex('make', '-j', $np, 'installcheck');
_text('mc.txt', $log);

print "Testing MPICH installation...\n";
chdir $rootdir . '/test/mpi';

# Unset Fortran 90 compiler flags
$ENV{'F90'}  = '';
$ENV{'F90FLAGS'} = '';

# Set Fortran compiler flags
$ENV{'FCFLAGS'} = $ENV{'FFLAGS'};

$log = capturex('./configure', "--with-mpi=$prefix");
_text('ct.txt', $log);

$log = capturex('make', '-j', $np, 'testing');
_text('mt.txt', $log);

## @eof mpich-install-gnu.pl


mpich-4.2.1-install.log
Description: Binary data

Maxim Abalenkov \\ maxim.abalen...@gmail.com+44 7 486 486 505 \\ www.maxim.abalenkov.uk