Skip to content

GCC 7.0.1, OpenCoarrays 1.8.10 build failure on FreeBSD #388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mexas opened this issue May 19, 2017 · 17 comments
Closed

GCC 7.0.1, OpenCoarrays 1.8.10 build failure on FreeBSD #388

mexas opened this issue May 19, 2017 · 17 comments

Comments

@mexas
Copy link

mexas commented May 19, 2017

full build log: http://eis.bris.ac.uk/~mexas/build.log
The error:

cd /usr/ports/lang/opencoarrays/work/.build/src/mpi && /usr/bin/cc -DGCC_GE_7 -DMPI_WORKING_MODULE -DPREFIX_NAME=_gfortran_caf_ -I/usr/local/include -I/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src -I/usr/ports/lang/opencoarrays/work/.build/mod -O2 -pipe  -fstack-protector -fno-strict-aliasing -O2 -pipe  -fstack-protector -fno-strict-aliasing -o CMakeFiles/caf_mpi.dir/mpi_caf.c.o   -c /usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c
/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3239:11: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
  switch (GFC_DTYPE_TYPE_SIZE (desc))
          ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:73:52: note: expanded from macro 'GFC_DTYPE_TYPE_SIZE'
#define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:71:35: note: expanded from macro 'GFC_DTYPE_TYPE_SIZE_MASK'
#define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
                                  ^~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:70:47: note: expanded from macro 'GFC_DTYPE_SIZE_MASK'
  ((~((ptrdiff_t) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3291:9: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
  if ( (GFC_DTYPE_TYPE_SIZE(desc)-GFC_DTYPE_CHARACTER)%64==0 )
        ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:73:52: note: expanded from macro 'GFC_DTYPE_TYPE_SIZE'
#define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:71:35: note: expanded from macro 'GFC_DTYPE_TYPE_SIZE_MASK'
#define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
                                  ^~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:70:47: note: expanded from macro 'GFC_DTYPE_SIZE_MASK'
  ((~((ptrdiff_t) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3301:67: warning: shifting a negative signed value is undefined [-Wshift-negative-value]
  caf_runtime_error ("Unsupported data type in collective: %ld\n",GFC_DTYPE_TYPE_SIZE (desc));
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:73:52: note: expanded from macro 'GFC_DTYPE_TYPE_SIScript started on Fri May 19 17:35:13 2017
Command: make
===>  License BSD3CLAUSE accepted by the user
define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
                                  ^~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:70:47: note: expanded from macro 'GFC_DTYPE_SIZE_MA
SK'
  ((~((ptrdiff_t) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3291:9: warning: shifting a
 negative signed value is undefined [-Wshift-negative-value]
  if ( (GFC_DTYPE_TYPE_SIZE(desc)-GFC_DTYPE_CHARACTER)%64==0 )
        ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:73:52: note: expanded from macro 'GFC_DTYPE_TYPE_SI
ZE'
#define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:71:35: note: expanded from macro 'GFC_DTYPE_TYPE_SI
ZE_MASK'
#define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
                                  ^~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:70:47: note: expanded from macro 'GFC_DTYPE_SIZE_MA
SK'
  ((~((ptrdiff_t) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3301:67: warning: shifting
a negative signed value is undefined [-Wshift-negative-value]
  caf_runtime_error ("Unsupported data type in collective: %ld\n",GFC_DTYPE_TYPE_SIZE (desc));
                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:73:52: note: expanded from macro 'GFC_DTYPE_TYPE_SI
ZE'
#define GFC_DTYPE_TYPE_SIZE(desc) ((desc)->dtype & GFC_DTYPE_TYPE_SIZE_MASK)
                                                   ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:71:35: note: expanded from macro 'GFC_DTYPE_TYPE_SI
ZE_MASK'
#define GFC_DTYPE_TYPE_SIZE_MASK (GFC_DTYPE_SIZE_MASK | GFC_DTYPE_TYPE_MASK)
                                  ^~~~~~~~~~~~~~~~~~~
/usr/local/include/libcaf-gfortran-descriptor.h:70:47: note: expanded from macro 'GFC_DTYPE_SIZE_MA
SK'
  ((~((ptrdiff_t) 0) >> GFC_DTYPE_SIZE_SHIFT) << GFC_DTYPE_SIZE_SHIFT)
   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^
/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3510:24: error: use of unde
clared identifier 'GFC_CAF_ARG_VALUE'
      if ((opr_flags & GFC_CAF_ARG_VALUE) > 0)
                       ^
/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3528:21: error: use of unde
clared identifier 'GFC_CAF_ARG_VALUE'
          if ((opr_flags & GFC_CAF_ARG_VALUE) > 0)
                           ^
/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3543:21: error: use of unde
clared identifier 'GFC_CAF_ARG_VALUE'
          if ((opr_flags & GFC_CAF_ARG_VALUE) > 0)
                           ^
3 warnings and 3 errors generated.
*** [src/mpi/CMakeFiles/caf_mpi.dir/mpi_caf.c.o] Error code 1

make[4]: stopped in /usr/ports/lang/opencoarrays/work/.build
@zbeekman
Copy link
Collaborator

zbeekman commented May 19, 2017

The log doesn't show:

  1. How CMake is invoked
  2. What the patches being applied are

Would it be possible to include this information?

It's strange, because GFC_CAF_ARG_VALUE is definitely defined in libcaf.h. Is there any way to build with GCC instead of Clang? (Also, Clang looks quite old... on Apple Clang is at 7.x)

@mexas
Copy link
Author

mexas commented May 22, 2017

working on your questions.
In the meantime - I'm updating the FreeBSD opencoarrays port from 1.8.4 to 1.8.10.
Here's the successful 1.8.4 build log, from the same box:
http://eis.bris.ac.uk/~mexas/opencoarrays-1.8.4-make.log

@mexas
Copy link
Author

mexas commented May 22, 2017

make CC=gcc7

works to build 1.8.10:

http://eis.bris.ac.uk/~mexas/opencoarrays-1.8.10-CC=gcc7-make.log

@mexas
Copy link
Author

mexas commented May 22, 2017

@mexas
Copy link
Author

mexas commented May 22, 2017

Regarding the invocation of cmake, isn't this what you are looking for
( from http://eis.bris.ac.uk/~mexas/opencoarrays-1.8.10-CC=gcc7-make.log )

-- Build files have been written to: /usr/ports/lang/opencoarrays/work/.build
===>  Building for opencoarrays-1.8.10_1
/usr/local/bin/cmake -H/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10 -B/usr/ports/lang/opencoarrays/work/.build --check-build-system CMakeFiles/Makefile.cmake 0
/usr/local/bin/cmake -E cmake_progress_start /usr/ports/lang/opencoarrays/work/.build/CMakeFiles /usr/ports/lang/opencoarrays/work/.build/CMakeFiles/progress.marks
/usr/bin/make -f CMakeFiles/Makefile2 all
--- src/mpi/CMakeFiles/caf_mpi.dir/all ---
/usr/bin/make -f src/mpi/CMakeFiles/caf_mpi.dir/build.make src/mpi/CMakeFiles/caf_mpi.dir/depend
--- src/mpi/CMakeFiles/caf_mpi.dir/depend ---
cd /usr/ports/lang/opencoarrays/work/.build && /usr/local/bin/cmake -E cmake_depends "Unix Makefiles" /usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10 /usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi /usr/ports/lang/opencoarrays/work/.build /usr/ports/lang/opencoarrays/work/.build/src/mpi /usr/ports/lang/opencoarrays/work/.build/src/mpi/CMakeFiles/caf_mpi.dir/DependInfo.cmake 

@mexas
Copy link
Author

mexas commented May 22, 2017

By the way, is opencoarrays build thread-safe?
By default, FreeBSD ports are built in parallel, using
the number of threads equal to the number of cores.
If it helps, here's a serial build:
http://eis.bris.ac.uk/~mexas/opencoarrays-1.8.10-clang-make-jobs-unsafe.log

make MAKE_JOBS_UNSAFE=yes

@zbeekman
Copy link
Collaborator

By the way, is opencoarrays build thread-safe?

Yes, unless you do something funky when patching it (debian's patch builds static+dynamic libs, and didn't engineer the patch to be thread safe... we're incorporating a thread safe version of their patch soon...)

Regarding the invocation of cmake, isn't this what you are looking for

No, what I am looking for looks like cmake [<options>] (<path-to-source> | <path-to-existing-build>) and happened somewhere between these two lines:

/bin/mkdir -p /usr/ports/lang/opencoarrays/work/.build
-- The C compiler identification is Clang 3.8.0

It also apparently includes the option -D CMAKE_CXX_COMPILER=some/cxx/compiler etc. Building with Homebrew on apple, the line looks like this: cmake .. -DCMAKE_C_FLAGS_RELEASE=-DNDEBUG -DCMAKE_CXX_FLAGS_RELEASE=-DNDEBUG -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencoarrays/HEAD-0d2ef3b -DCMAKE_BUILD_TYPE=Release -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev

make CC=gcc7
works to build 1.8.10:

Great! As I mentioned before, AppleClang 7.0.2.7000181 doesn't seem to have any issues building OpenCoarrays. My suspicion is that your Clang is doing something wrong or funky.

The bottom line is that something went wrong with the includes, since compiling with Clang, the error is:

/usr/ports/lang/opencoarrays/work/OpenCoarrays-1.8.10/src/mpi/mpi_caf.c:3543:21: error: use of undeclared identifier 'GFC_CAF_ARG_VALUE'
          if ((opr_flags & GFC_CAF_ARG_VALUE) > 0)
                           ^

BUT, GFC_CAF_ARG_VALUE IS declared in libcaf.h.

It's possible that the this might be able to be fixed with a change to the build system (i.e. if the order of the include flags needs to be changed or by passing a full path to libcaf.h etc.) but I'm quite tempted to close this as "won't fix" since it works with GCC 7 and Clang on Apple.

Regarding your patches:

  • I find it odd that you need to disable the C "Hello world" MPI program test in https://svnweb.freebsd.org/ports/head/lang/opencoarrays/files/patch-CMakeLists.txt?view=markup. What goes wrong when you leave it in place? (The contents of CMakeFiles/CMakeError.log in the build directory should provide some insight. If you feel inclined to try this out, please copy /usr/ports/lang/opencoarrays/work/.build/CMakeFiles/CMakeError.log here.)
  • I don't think the patch to src/mpi/CMakeLists.txt is needed anymore and it most likely won't apply cleanly. We have included a version of this patch upstream. (Although we left user write permissions in place, i.e., rwxr-xr-x.)

@mexas
Copy link
Author

mexas commented May 23, 2017

  1. Regarding clang. You mention Apple clang at version 7.
    The latest stable version seems to be 4:
    http://releases.llvm.org/download.html
    and the latest dev branch is 5.

Yes, I can build opencoarrays 1.8.10 with clang 5:
http://eis.bris.ac.uk/~mexas/opencoarrays-1.8.10-clang5-make.log

I guess I need to send this to the clang team.

  1. Regarding the patches - I need to double check why
    we removed the hello world. The other patch you refer to
    will be gone once my changes have been committed.

yes, ok to close this PR.

Thanks

@zbeekman
Copy link
Collaborator

Hi Anton,

One final question:

I notice that mpi_caf.c is also patched to remove #include <alloca.h>. To be honest, I don't have much experience with this header/library... from my internet searches it looks like it is just a drop in that can make some memory operations faster on some systems. I'm guessing it is removed in the patch because it's not available on BSD, is this correct?

If so I can add some introspection to the build system to see if it is present and if it is missing, remove it from mpi_caf.c. What do you think?

@mexas
Copy link
Author

mexas commented May 23, 2017

On FreeBSD alloca is in libc:
https://www.freebsd.org/cgi/man.cgi?query=alloca
so there is no separate alloca.h.
Yes, I think what you suggest is sound.
Thanks

@mexas
Copy link
Author

mexas commented May 23, 2017

BTW, don't know why we removed hello world,
might have been in the early stages of porting,
to narrow down the sources of build errors.
I removed that patch and all is well.
So we now have only the alloca patch on FreeBSD.

@zbeekman
Copy link
Collaborator

zbeekman commented May 23, 2017 via email

@zbeekman
Copy link
Collaborator

So we now have only the alloca patch on FreeBSD.

Once 151eb80 hits master/the next release, that last patch should no longer be required...

zbeekman referenced this issue May 23, 2017
 - Test for existence, assume symbols/functionality provided elsewhere
   if it is missing. Should induce compile time error if this is not
   true.
@zbeekman
Copy link
Collaborator

Hi Anton,

Can you please try the attached patch for the older clang and let me know how it goes? I added a little bit of debugging, so if it doesn't work, please upload the log again, and I may be able to get some more insight into why it's failing.
1_8_10_clang_fix.patch.txt

From 4decd152dc9a492feca2d694785da4ea4cf50ecc Mon Sep 17 00:00:00 2001
From: Izaak Beekman <[email protected]>
Date: Tue, 23 May 2017 18:54:30 -0400
Subject: [PATCH] Patch *may* fix old clang issue, add new debuging

---
CMakeLists.txt         | 2 +-
src/mpi/CMakeLists.txt | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7f7b61..7ebc23b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -383,7 +383,7 @@ include(GNUInstallDirs)
#-------------------------------
# Recurse into the src directory
#-------------------------------
-include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
+include_directories(BEFORE ${CMAKE_CURRENT_SOURCE_DIR}/src)

add_subdirectory(src)

diff --git a/src/mpi/CMakeLists.txt b/src/mpi/CMakeLists.txt
index 6f4490b..a4feb5a 100644
--- a/src/mpi/CMakeLists.txt
+++ b/src/mpi/CMakeLists.txt
@@ -57,6 +57,10 @@ install(TARGETS caf_mpi EXPORT OpenCoarraysTargets
  LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}"
)

+get_target_property(libcaf_mpi_includes caf_mpi INCLUDE_DIRECTORIES)
+message( STATUS "Include directories for libmpi_caf:\n\
+    ${libcaf_mpi_includes}")
+
# Install modules to standard include dir, but namespace them with compiler/version
set (mod_install "OpenCoarrays/${CMAKE_Fortran_COMPILER_ID}/${CMAKE_Fortran_COMPILER_VERSION}")
install(DIRECTORY  "${CMAKE_BINARY_DIR}/mod/"
-- 
2.13.0

zbeekman added a commit that referenced this issue May 23, 2017
 May fix #388 (issue with Clang 4 on FreeBSD)
zbeekman added a commit that referenced this issue May 25, 2017
Pull in failed images support.

 - Fixes #309 
 - Fixes #354 
 - Fixes #388 
 - Fixes #390
@mexas
Copy link
Author

mexas commented May 26, 2017

just to confirm - 1.8.12 builds fine with no patches with clang 3.8.0.

@zbeekman
Copy link
Collaborator

zbeekman commented May 26, 2017 via email

@mexas
Copy link
Author

mexas commented May 26, 2017

Many tests still fail, I updated #348.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants