[cmake-developers] Incomplete gfortran library link command sometimes mysteriously occurs with MinGW/MSYS on Wine-1.5.15 platform

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Oct 22 03:34:13 EDT 2012


On 2012-10-19 13:39-0400 Bill Hoffman wrote:

> On 10/19/2012 1:24 PM, Alan W. Irwin wrote:
>> 
>> So far this morning there have been no takers, but I hope that changes
>> since I am really stumped by CMake _intermittently_ not issuing the
>> correct link command for libraries with no consistent pattern I can
>> spot with regard to anything I change.
>
> Couple of things to try:
>
> run --trace on cmake and compare them.  Maybe something odd is happening with 
> your cmake variables.   Also, look at the generated makefiles and find out 
> what is different between the ones that work and the ones that don't.
>
> If this can not be reproduced by running a set command line (some script you 
> write)...

Thanks for those suggestions, Bill.

The current status is I have sent a complete test case to David Cole
who plans to run it when he has a chance this week on at least one
Windows platform available to him.  That test should show just how
easy this issue is to replicate (or not).

For that test case here, CMakes generates a bad link command for the epcomf Fortran
library for the downloaded Windows binary version of CMake-2.8.9, but I have
just discovered that a bootstrapped build of CMake-2.8.9 (using
MinGW/MSYS for version 4.5.2 of gcc) generates the correct Fortran link
command.  I have attached the two relevant build.make files for you
and David to look at.  The diff between them shows a lot of noise
due to different names for libraries used by downloaded versus bootstrapped
CMake.  I eliminated that diff noise as follows:

wine at raven> sed -e "s?libephcom?ephcom?g" -e "s?libgnulliver?gnulliver?g"
-e"s?\.dll\.a?.lib?g" /tmp/build.make |diff -au /tmp/bad_build.make -

The result was

--- /tmp/bad_build.make	2012-10-20 12:57:03.575441788 -0700
+++ -	2012-10-20 12:59:56.777968384 -0700
@@ -26,17 +26,14 @@
  SHELL = /bin/sh

  # The CMake executable.
-CMAKE_COMMAND = /Z/home/wine/newstart/cmake-2.8.9-win32-x86/bin/cmake.exe
+CMAKE_COMMAND = /Z/home/wine/newstart/bootstrap_cmake/install_4.5.2/bin/cmake.exe

  # The command to remove a file.
-RM = /Z/home/wine/newstart/cmake-2.8.9-win32-x86/bin/cmake.exe -E remove -f
+RM = /Z/home/wine/newstart/bootstrap_cmake/install_4.5.2/bin/cmake.exe -E remove -f

  # Escaping for special characters.
  EQUALS = =

-# The program to use to edit the cache.
-CMAKE_EDIT_COMMAND = /Z/home/wine/newstart/cmake-2.8.9-win32-x86/bin/cmake-gui.exe
-
  # The top-level source directory on which CMake was run.
  CMAKE_SOURCE_DIR = /z/home/wine/newstart/ephcom2_20121019

@@ -53,6 +50,7 @@
  include bindings/f95/CMakeFiles/ephcomf.dir/flags.make

  bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj: bindings/f95/CMakeFiles/ephcomf.dir/flags.make
+bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj: bindings/f95/CMakeFiles/ephcomf.dir/includes_Fortran.rsp
  bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj: z:/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf.f
  	$(CMAKE_COMMAND) -E cmake_progress_report /Z/home/wine/newstart/ephcom2/build_dir/CMakeFiles $(CMAKE_PROGRESS_1)
  	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building Fortran object bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj"
@@ -81,8 +79,11 @@
  dll/ephcomf.dll: dll/ephcom.lib
  dll/ephcomf.dll: dll/gnulliver.lib
  dll/ephcomf.dll: z:/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf_mingw.def
+dll/ephcomf.dll: bindings/f95/CMakeFiles/ephcomf.dir/objects1.rsp
  	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking Fortran shared library ../../dll/ephcomf.dll"
-	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /z/home/wine/newstart/MinGW/bin/gfortran.exe      /z/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf_mingw.def -shared  -o ../../dll/ephcomf.dll $(ephcomf_OBJECTS) $(ephcomf_EXTERNAL_OBJECTS) ../../dll/ephcomfc.lib ../../dll/ephcomc.lib ../../dll/ephcom.lib ../../dll/gnulliver.lib 
+	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /Z/home/wine/newstart/bootstrap_cmake/install_4.5.2/bin/cmake.exe -E remove -f CMakeFiles/ephcomf.dir/objects.a
+	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /z/home/wine/newstart/MinGW/bin/ar.exe cr CMakeFiles/ephcomf.dir/objects.a @CMakeFiles/ephcomf.dir/objects1.rsp
+	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /z/home/wine/newstart/MinGW/bin/gfortran.exe     /z/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf_mingw.def -shared -o ../../dll/ephcomf.dll -Wl,--out-implib,../../dll/ephcomf.lib -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles/ephcomf.dir/objects.a -Wl,--no-whole-archive ../../dll/ephcomfc.lib ../../dll/ephcomc.lib ../../dll/ephcom.lib ../../dll/gnulliver.lib

  # Rule to build all files generated by this target.
  bindings/f95/CMakeFiles/ephcomf.dir/build: dll/ephcomf.dll

You can see the link commands are very different, but also it is
intriguing there are other differences as well between CMake results
generated with two different compilers _for exactly the same source
version of CMake_.  Do any of those further changes and/or the name
changes ring a bell for which part of the CMake code or particular
variable in that code is the critical one for causing these big
differences in results for the fortran link command?

One possibility to explain these differences is there is a bug in the
C++ compiler (whatever that might be) used to generate the
downloadable Windows binary version of CMake.  But an alternative
hypothesis is that C++ compiler uses newer Windows API (at least for
that part of the CMake code that is used to generate the Fortran library
link command) that Wine does not implement well while the C++ compiler
included with MinGW-4.5.2 may be sticking to older Windows API that
Wine does implement well.

So if there is a C++ compiler bug, the test planned by David should
show that, but if he finds that CMake issues a good Fortran library
link command for my test case no matter what C++ compiler is used to
build CMake there on Windows, then that pretty much rules out a
compiler bug, and improves the chances that the second scenario above
is the correct one.

The third scenario (memory management issues in the CMake source code)
is still in the running because all such issues are hard to replicate.
However, the probability of this scenario has faded fast this weekend
because I have gotten good generated link command results with a
number of different tests of both ephcom and te_gen for the version of
CMake bootstrapped with MinGW and MSYS corresponding to gcc-4.5.2.

Those te_gen Fortran run-time issues I mentioned before for the MinGW
equivalent of gcc-4.6.2 are still there for MinGW/gcc-4.5.2, but I
have gotten rid of lots of secondary error noise with this issue 
(which also occurred on Linux when I used a deliberately bad
filename). The remaining Wine platform issue is simply that the
filename string is incorrectly being replaced by an empty string by my
standard te_gen test on Wine. I suspect some issue like trimming blank
characters off the end of the string is removing the whole string
instead, but in any case I hope to find the ultimate source of this
Wine issue tomorrow and work around it.  At that point I might be able
to complete my te_gen tests on Wine which would be a really nice step
forward compared to the gloomy MinGW/MSYS Wine platform prospects a
couple of days ago.

So in sum, things are looking much better on the MinGW/MSYS/Wine
platform so long as I stick to bootstrapped versions of CMake, and
David's forthcoming test of the complete test case I gave him should
help to sort out some possibilities why there are issues with the
Fortran link command being generated by the downloaded Windows binary
version of CMake on the Wine platform.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state
implementation for stellar interiors (freeeos.sf.net); the Time
Ephemerides project (timeephem.sf.net); PLplot scientific plotting
software package (plplot.sf.net); the libLASi project
(unifont.org/lasi); the Loads of Linux Links project (loll.sf.net);
and the Linux Brochure Project (lbproject.sf.net).
__________________________

Linux-powered Science
__________________________
-------------- next part --------------
# CMAKE generated file: DO NOT EDIT!

# Generated by "MSYS Makefiles" Generator, CMake Version 2.8



#=============================================================================

# Special targets provided by cmake.



# Disable implicit rules so canonical targets will work.

.SUFFIXES:



# Remove some rules from gmake that .SUFFIXES does not remove.

SUFFIXES =



.SUFFIXES: .hpux_make_needs_suffix_list



# Suppress display of executed commands.

$(VERBOSE).SILENT:



# A target that is always out of date.

cmake_force:

.PHONY : cmake_force



#=============================================================================

# Set environment variables for the build.



# The shell in which to execute make rules.

SHELL = /bin/sh



# The CMake executable.

CMAKE_COMMAND = /Z/home/wine/newstart/bootstrap_cmake/install_4.5.2/bin/cmake.exe



# The command to remove a file.

RM = /Z/home/wine/newstart/bootstrap_cmake/install_4.5.2/bin/cmake.exe -E remove -f



# Escaping for special characters.

EQUALS = =



# The top-level source directory on which CMake was run.

CMAKE_SOURCE_DIR = /z/home/wine/newstart/ephcom2_20121019



# The top-level build directory on which CMake was run.

CMAKE_BINARY_DIR = /Z/home/wine/newstart/ephcom2/build_dir



# Include any dependencies generated for this target.

include bindings/f95/CMakeFiles/ephcomf.dir/depend.make



# Include the progress variables for this target.

include bindings/f95/CMakeFiles/ephcomf.dir/progress.make



# Include the compile flags for this target's objects.

include bindings/f95/CMakeFiles/ephcomf.dir/flags.make



bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj: bindings/f95/CMakeFiles/ephcomf.dir/flags.make

bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj: bindings/f95/CMakeFiles/ephcomf.dir/includes_Fortran.rsp

bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj: z:/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf.f

	$(CMAKE_COMMAND) -E cmake_progress_report /Z/home/wine/newstart/ephcom2/build_dir/CMakeFiles $(CMAKE_PROGRESS_1)

	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building Fortran object bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj"

	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /z/home/wine/newstart/MinGW/bin/gfortran.exe  $(Fortran_DEFINES) $(Fortran_FLAGS) -cpp -c /z/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf.f -o CMakeFiles/ephcomf.dir/ephcomf.f.obj



bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.requires:

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.requires



bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.provides: bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.requires

	$(MAKE) -f bindings/f95/CMakeFiles/ephcomf.dir/build.make bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.provides.build

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.provides



bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.provides.build: bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj



# Object files for target ephcomf

ephcomf_OBJECTS = \

"CMakeFiles/ephcomf.dir/ephcomf.f.obj"



# External object files for target ephcomf

ephcomf_EXTERNAL_OBJECTS =



dll/libephcomf.dll: bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj

dll/libephcomf.dll: bindings/f95/CMakeFiles/ephcomf.dir/build.make

dll/libephcomf.dll: dll/libephcomfc.dll.a

dll/libephcomf.dll: dll/libephcomc.dll.a

dll/libephcomf.dll: dll/libephcom.dll.a

dll/libephcomf.dll: dll/libgnulliver.dll.a

dll/libephcomf.dll: z:/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf_mingw.def

dll/libephcomf.dll: bindings/f95/CMakeFiles/ephcomf.dir/objects1.rsp

	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking Fortran shared library ../../dll/libephcomf.dll"

	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /Z/home/wine/newstart/bootstrap_cmake/install_4.5.2/bin/cmake.exe -E remove -f CMakeFiles/ephcomf.dir/objects.a

	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /z/home/wine/newstart/MinGW/bin/ar.exe cr CMakeFiles/ephcomf.dir/objects.a @CMakeFiles/ephcomf.dir/objects1.rsp

	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /z/home/wine/newstart/MinGW/bin/gfortran.exe     /z/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf_mingw.def -shared -o ../../dll/libephcomf.dll -Wl,--out-implib,../../dll/libephcomf.dll.a -Wl,--major-image-version,0,--minor-image-version,0 -Wl,--whole-archive CMakeFiles/ephcomf.dir/objects.a -Wl,--no-whole-archive ../../dll/libephcomfc.dll.a ../../dll/libephcomc.dll.a ../../dll/libephcom.dll.a ../../dll/libgnulliver.dll.a 



# Rule to build all files generated by this target.

bindings/f95/CMakeFiles/ephcomf.dir/build: dll/libephcomf.dll

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/build



bindings/f95/CMakeFiles/ephcomf.dir/requires: bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.requires

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/requires



bindings/f95/CMakeFiles/ephcomf.dir/clean:

	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && $(CMAKE_COMMAND) -P CMakeFiles/ephcomf.dir/cmake_clean.cmake

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/clean



bindings/f95/CMakeFiles/ephcomf.dir/depend:

	$(CMAKE_COMMAND) -E cmake_depends "MSYS Makefiles" /z/home/wine/newstart/ephcom2_20121019 /z/home/wine/newstart/ephcom2_20121019/bindings/f95 /Z/home/wine/newstart/ephcom2/build_dir /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95/CMakeFiles/ephcomf.dir/DependInfo.cmake --color=$(COLOR)

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/depend



-------------- next part --------------
# CMAKE generated file: DO NOT EDIT!

# Generated by "MSYS Makefiles" Generator, CMake Version 2.8



#=============================================================================

# Special targets provided by cmake.



# Disable implicit rules so canonical targets will work.

.SUFFIXES:



# Remove some rules from gmake that .SUFFIXES does not remove.

SUFFIXES =



.SUFFIXES: .hpux_make_needs_suffix_list



# Suppress display of executed commands.

$(VERBOSE).SILENT:



# A target that is always out of date.

cmake_force:

.PHONY : cmake_force



#=============================================================================

# Set environment variables for the build.



# The shell in which to execute make rules.

SHELL = /bin/sh



# The CMake executable.

CMAKE_COMMAND = /Z/home/wine/newstart/cmake-2.8.9-win32-x86/bin/cmake.exe



# The command to remove a file.

RM = /Z/home/wine/newstart/cmake-2.8.9-win32-x86/bin/cmake.exe -E remove -f



# Escaping for special characters.

EQUALS = =



# The program to use to edit the cache.

CMAKE_EDIT_COMMAND = /Z/home/wine/newstart/cmake-2.8.9-win32-x86/bin/cmake-gui.exe



# The top-level source directory on which CMake was run.

CMAKE_SOURCE_DIR = /z/home/wine/newstart/ephcom2_20121019



# The top-level build directory on which CMake was run.

CMAKE_BINARY_DIR = /Z/home/wine/newstart/ephcom2/build_dir



# Include any dependencies generated for this target.

include bindings/f95/CMakeFiles/ephcomf.dir/depend.make



# Include the progress variables for this target.

include bindings/f95/CMakeFiles/ephcomf.dir/progress.make



# Include the compile flags for this target's objects.

include bindings/f95/CMakeFiles/ephcomf.dir/flags.make



bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj: bindings/f95/CMakeFiles/ephcomf.dir/flags.make

bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj: z:/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf.f

	$(CMAKE_COMMAND) -E cmake_progress_report /Z/home/wine/newstart/ephcom2/build_dir/CMakeFiles $(CMAKE_PROGRESS_1)

	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --green "Building Fortran object bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj"

	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /z/home/wine/newstart/MinGW/bin/gfortran.exe  $(Fortran_DEFINES) $(Fortran_FLAGS) -cpp -c /z/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf.f -o CMakeFiles/ephcomf.dir/ephcomf.f.obj



bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.requires:

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.requires



bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.provides: bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.requires

	$(MAKE) -f bindings/f95/CMakeFiles/ephcomf.dir/build.make bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.provides.build

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.provides



bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.provides.build: bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj



# Object files for target ephcomf

ephcomf_OBJECTS = \

"CMakeFiles/ephcomf.dir/ephcomf.f.obj"



# External object files for target ephcomf

ephcomf_EXTERNAL_OBJECTS =



dll/ephcomf.dll: bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj

dll/ephcomf.dll: bindings/f95/CMakeFiles/ephcomf.dir/build.make

dll/ephcomf.dll: dll/ephcomfc.lib

dll/ephcomf.dll: dll/ephcomc.lib

dll/ephcomf.dll: dll/ephcom.lib

dll/ephcomf.dll: dll/gnulliver.lib

dll/ephcomf.dll: z:/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf_mingw.def

	@$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --red --bold "Linking Fortran shared library ../../dll/ephcomf.dll"

	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && /z/home/wine/newstart/MinGW/bin/gfortran.exe      /z/home/wine/newstart/ephcom2_20121019/bindings/f95/ephcomf_mingw.def -shared  -o ../../dll/ephcomf.dll $(ephcomf_OBJECTS) $(ephcomf_EXTERNAL_OBJECTS) ../../dll/ephcomfc.lib ../../dll/ephcomc.lib ../../dll/ephcom.lib ../../dll/gnulliver.lib 



# Rule to build all files generated by this target.

bindings/f95/CMakeFiles/ephcomf.dir/build: dll/ephcomf.dll

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/build



bindings/f95/CMakeFiles/ephcomf.dir/requires: bindings/f95/CMakeFiles/ephcomf.dir/ephcomf.f.obj.requires

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/requires



bindings/f95/CMakeFiles/ephcomf.dir/clean:

	cd /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 && $(CMAKE_COMMAND) -P CMakeFiles/ephcomf.dir/cmake_clean.cmake

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/clean



bindings/f95/CMakeFiles/ephcomf.dir/depend:

	$(CMAKE_COMMAND) -E cmake_depends "MSYS Makefiles" /z/home/wine/newstart/ephcom2_20121019 /z/home/wine/newstart/ephcom2_20121019/bindings/f95 /Z/home/wine/newstart/ephcom2/build_dir /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95 /Z/home/wine/newstart/ephcom2/build_dir/bindings/f95/CMakeFiles/ephcomf.dir/DependInfo.cmake --color=$(COLOR)

.PHONY : bindings/f95/CMakeFiles/ephcomf.dir/depend





More information about the cmake-developers mailing list