Menu

#5799 Fixes for cross-compilation to x86_64-w64-mingw32

Fixed
2020-03-07
2020-02-27
No

Fixes for cross-compilation to x86_64-w64-mingw32

1) Include config.hh before cmath

Recently commit 7396a28bde ("Add enabling extension definitions for
-std=c++11 option") added a few #defines to config.hh to make POSIX
extensions available. Make sure that they are pulled in from config.hh
before cmath is included.

2) Improve cast from pointer to integer

When cross-compiling to x86_64-w64-mingw32, 'long' (32 bit) is smaller
than 'void *' (64 bit). This leads to compiler errors because the cast
truncates. After analysis I think that truncation is actually ok here,
so make this explicit by first casting to a suitable integer and then
truncate to long.
Note that 'suitable integer' is quite a mess: Ideally we would use
intptr_t, but it's optional per the C++ standard. So instead rely on
intmax_t and hope that it works.

3) Use host triple when looking for windres

--host=host-type
the type of system on which the package runs. [...]

The $target variable is meant for compilers. However, it is still needed
for compatibility with GUB / i686-mingw32.

4) Rename DATADIR to CONFIG_DATADIR

The header objidl.h from mingw has an enum called DATADIR. This
conflicts with our definition and results in compilation errors
because the preprocessor replaces the enum name with the configured
string. This is apparently dealt with in mingw-compatibility.hh,
but not in the configure checks. As a result, they return the wrong
answer which leads to further compilation errors down the road.

http://codereview.appspot.com/579340043

Discussion

  • Anonymous

    Anonymous - 2020-02-28
    • Description has changed:

    Diff:

    
    
    • Needs: -->
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-02-28

    Passes make, make check and a full make doc.

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-28
     
  • Anonymous

    Anonymous - 2020-02-28

    Passes make, make check and a full make doc.

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-29

    Rename DATADIR to CONFIG_DATADIR

    http://codereview.appspot.com/579340043

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-02-29
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -33,4 +33,13 @@
     Please refer to section 14.1 Specifying target triplets in the Autoconf
     documentation for more details.
    
    +4) Rename DATADIR to CONFIG_DATADIR
    +    
    +The header objidl.h from mingw has an enum called DATADIR. This
    +conflicts with our definition and results in compilation errors
    +because the preprocessor replaces the enum name with the configured
    +string. This is apparently dealt with in mingw-compatibility.hh,
    +but not in the configure checks. As a result, they return the wrong
    +answer which leads to further compilation errors down the road.
    +
     http://codereview.appspot.com/579340043
    
    • Needs: -->
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-02-29
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-02-29

    Passes make, make check and a full make doc.

     
  • Anonymous

    Anonymous - 2020-03-01
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-03-01

    Patch on countdown for March 3rd

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-03-02
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-03-02
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -1,16 +1,11 @@
     Fixes for cross-compilation to x86_64-w64-mingw32
    
    -1) Define _POSIX_SOURCE for M_PI on mingw
    +1) Include config.hh before cmath
    
     Recently commit 7396a28bde ("Add enabling extension definitions for
     `-std=c++11` option") added a few #defines to config.hh to make POSIX
    -extensions available. This doesn't seem to work in all cases and I
    -found this change to fix cross-compilation to x86_64-w64-mingw32.
    -
    -In general I think this method of explicitly spelling out what each
    -file needs is superior to gathering all of this in config.hh. It serves
    -as documentation directly in the code and makes sure that the feature
    -macro is defined before any other header file is included.
    +extensions available. Make sure that they are pulled in from config.hh
    +before cmath is included.
    
     2) Improve cast from pointer to integer
    
    • Needs: -->
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-03-02
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-03-02

    Passes make, make check and a full make doc.

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-03-02
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-03-02
    • Description has changed:

    Diff:

    --- old
    +++ new
    @@ -23,10 +23,8 @@
     --host=host-type
         the type of system on which the package runs. [...]
    
    -The previously used $target variable is meant for compilers.
    -
    -Please refer to section 14.1 Specifying target triplets in the Autoconf
    -documentation for more details.
    +The $target variable is meant for compilers. However, it is still needed
    +for compatibility with GUB / i686-mingw32.
    
     4) Rename DATADIR to CONFIG_DATADIR
    
    • Needs: -->
    • Type: -->
     
  • Anonymous

    Anonymous - 2020-03-02
    • Patch: new --> review
     
  • Anonymous

    Anonymous - 2020-03-02

    Passes make, make check and a full make doc.

     
  • Anonymous

    Anonymous - 2020-03-05
    • Patch: review --> countdown
     
  • Anonymous

    Anonymous - 2020-03-05

    Patch on countdown for March 7th

     
  • Anonymous

    Anonymous - 2020-03-07
    • Patch: countdown --> push
     
  • Anonymous

    Anonymous - 2020-03-07

    Patch counted down - please push.

     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-03-07
    • labels: --> Fixed_2_21_0
    • status: Started --> Fixed
    • Patch: push -->
     
  • Jonas Hahnfeld

    Jonas Hahnfeld - 2020-03-07
    commit f7df92a65504ff80d58c2f01425fa24e4ce282af
    Author:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    AuthorDate: Sat Feb 29 11:14:45 2020 +0100
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Sat Mar 7 11:06:40 2020 +0100
    
        Issue 5799/4: Rename DATADIR to CONFIG_DATADIR
    
        The header objidl.h from mingw has an enum called DATADIR. This
        conflicts with our definition and results in compilation errors
        because the preprocessor replaces the enum name with the configured
        string. This is apparently dealt with in mingw-compatibility.hh,
        but not in the configure checks. As a result, they return the wrong
        answer which leads to further compilation errors down the road.
    
    commit 49a6e9c2a332afb31f3823649fdc38a325942b22
    Author:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    AuthorDate: Wed Feb 26 20:21:02 2020 +0100
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Sat Mar 7 11:06:40 2020 +0100
    
        Issue 5799/3: Use host triple when looking for windres
    
        --host=host-type
            the type of system on which the package runs. [...]
    
        The $target variable is meant for compilers. However, it is still needed
        for compatibility with GUB / i686-mingw32.
    
    commit 7197db282cf197e451e55554f1e1ab5f982a9817
    Author:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    AuthorDate: Wed Feb 26 19:27:04 2020 +0100
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Sat Mar 7 11:06:40 2020 +0100
    
        Issue 5799/2: Improve cast from pointer to integer
    
        When cross-compiling to x86_64-w64-mingw32, 'long' (32 bit) is smaller
        than 'void *' (64 bit). This leads to compiler errors because the cast
        truncates. After analysis I think that truncation is actually ok here,
        so make this explicit by first casting to a suitable integer and then
        truncate to long.
        Note that 'suitable integer' is quite a mess: Ideally we would use
        intptr_t, but it's optional per the C++ standard. So instead rely on
        intmax_t and hope that it works.
    
    commit 7cb1141f39e7508418b83038941409c5943b69c9
    Author:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    AuthorDate: Sun Mar 1 21:00:51 2020 +0100
    Commit:     Jonas Hahnfeld <hahnjo@hahnjo.de>
    CommitDate: Sat Mar 7 11:06:40 2020 +0100
    
        Issue 5799/1: Include config.hh before cmath
    
        Recently commit 7396a28bde ("Add enabling extension definitions for
        `-std=c++11` option") added a few #defines to config.hh to make POSIX
        extensions available. Make sure that they are pulled in from config.hh
        before cmath is included.