Skip to content
This repository was archived by the owner on Aug 3, 2021. It is now read-only.

Conversation

thaJeztah
Copy link
Member

alternative to #1
closes #1

relates to moby/moby#39880

Debian buster installs gcc-mingw-w64 8.3, causing compilation to
fail due to the hard-coded path for includes.

In file included from /usr/x86_64-w64-mingw32/include/minwindef.h:163,
                 from /usr/x86_64-w64-mingw32/include/windef.h:8,
                 from /usr/x86_64-w64-mingw32/include/windows.h:69,
                 from containerutility.h:3,
                 from argumentstream.cpp:1:
/usr/x86_64-w64-mingw32/include/winnt.h:1554:11: fatal error: x86intrin.h: No such file or directory
 # include <x86intrin.h>
           ^~~~~~~~~~~~~
compilation terminated.

This patch removes the hard-coded paths to consider for includes, and instead
enables the standard include paths by removing the -nostdinc option.

With this option removed, the following paths are considered on Debian buster:

x86_64-w64-mingw32-g++ -print-search-dirs
install: /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/
programs: =/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/bin/
libraries: =/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib/

And compilation succeeds without having to manually specify paths:

x86_64-w64-mingw32-g++ -fno-exceptions -std=c++11 -static -DUNICODE -municode -O3 -s -o containerutility.exe argumentstream.cpp commands.cpp containerutility.cpp identity.cpp version.cpp
echo $?
0

There might have been a specific reason for hard-coding the paths and excluding
the standard paths, but no history could be found for this.

Signed-off-by: Sebastiaan van Stijn github@gone.nl

Debian buster installs gcc-mingw-w64 8.3, causing compilation to
fail due to the hard-coded path for includes.

```
In file included from /usr/x86_64-w64-mingw32/include/minwindef.h:163,
                 from /usr/x86_64-w64-mingw32/include/windef.h:8,
                 from /usr/x86_64-w64-mingw32/include/windows.h:69,
                 from containerutility.h:3,
                 from argumentstream.cpp:1:
/usr/x86_64-w64-mingw32/include/winnt.h:1554:11: fatal error: x86intrin.h: No such file or directory
 # include <x86intrin.h>
           ^~~~~~~~~~~~~
compilation terminated.
```

This patch removes the hard-coded paths to consider for includes, and instead
enables the standard include paths by removing the `-nostdinc` option.

With this option removed, the following paths are considered on Debian buster:

```
x86_64-w64-mingw32-g++ -print-search-dirs
install: /usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/
programs: =/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/bin/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/bin/
libraries: =/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib/x86_64-w64-mingw32/8.3-win32/:/usr/lib/gcc/x86_64-w64-mingw32/8.3-win32/../../../../x86_64-w64-mingw32/lib/
```

And compilation succeeds without having to manually specify paths:

```
x86_64-w64-mingw32-g++ -fno-exceptions -std=c++11 -static -DUNICODE -municode -O3 -s -o containerutility.exe argumentstream.cpp commands.cpp containerutility.cpp identity.cpp version.cpp
echo $?
0
```

There might have been a specific reason for hard-coding the paths and excluding
the standard paths, but no history could be found for this.

Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah
Copy link
Member Author

ping @chris-crone @vikramhh @johnstep @ddebroy PTAL

Copy link

@chris-crone chris-crone left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, LGTM.

It would be good to have someone more Windows (mingw) oriented to do a pass and let us know if we're missing something.

@thaJeztah
Copy link
Member Author

ping @simonferquel PTAL

@simonferquel
Copy link

I don't have much experience with mingw, but building with default include headers seems likely to be the right thing to do.

@thaJeztah
Copy link
Member Author

Discussed with @johnstep as well, and he also couldn't think of a reason for not using the standard paths. I'll merge this change.

@thaJeztah thaJeztah merged commit aa1ba87 into docker-archive:master Feb 14, 2020
@thaJeztah thaJeztah deleted the use_stdinc_paths branch February 14, 2020 22:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants