Skip to content
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

[vcpkg baseline][gdk-pixbuf] Fix build error on windows #17528

Merged
merged 10 commits into from
Apr 28, 2021

Conversation

PhoebeHui
Copy link
Contributor

@PhoebeHui PhoebeHui commented Apr 27, 2021

Related to #17431

It looks 'has_function' in https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/blob/master/meson.build#L93 generate wrong check code here with vs2019. just replace the functions with correct check code. this issue occurred on vs2019, it compiles fine with vs2017.

Fix the failures:
E:\vcpkg\clean\vcpkg\buildtrees\gdk-pixbuf\src\k-pixbuf-2-c86079bed6\gdk-pixbuf\pixops../fallback-c89.c(38): error C2169: 'lrint': intrinsic function, cannot be defined

Upstream issue https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/187.
Meson issue: mesonbuild/meson#8703 mesonbuild/meson#8702.

@PhoebeHui PhoebeHui added category:port-bug The issue is with a library, which is something the port should already support info:internal This PR or Issue was filed by the vcpkg team. labels Apr 27, 2021
@Neumann-A
Copy link
Contributor

wrong fix the correct fix is to have the check call the function with the correct parameters

@PhoebeHui
Copy link
Contributor Author

PhoebeHui commented Apr 27, 2021

@Neumann-A, thanks for your review!

After some investigations, it looks 'has_function' in https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/blob/master/meson.build#L93 generate wrong check code here with vs2019.

meson.build log:

Running compile:
Working directory:  E:\vcpkg\clean\vcpkg\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmpywbswwxp
Command line:  C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe -INCREMENTAL:NO -I"E:/vcpkg/clean/vcpkg/installed/x64-windows/include" E:\vcpkg\clean\vcpkg\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmpywbswwxp\testfile.c /FeE:\vcpkg\clean\vcpkg\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmpywbswwxp\output.exe /nologo /showIncludes /MD -nologo -DWIN32 -D_WINDOWS -W3 -utf-8 -MP -MD -O2 -Oi -Gy -DNDEBUG -Z7 /nologo /showIncludes /Od kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib /link -machine:x64 -DEBUG -OPT:REF -OPT:ICF /LIBPATH:E:/vcpkg/clean/vcpkg/installed/x64-windows/lib 
Code:
 
        #define lrint meson_disable_define_of_lrint
        
        #include <limits.h>
        #undef lrint
        
        #ifdef __cplusplus
        extern "C"
        #endif
        char lrint (void);
        
        #if defined __stub_lrint || defined __stub___lrint
        fail fail fail this function is not going to work
        #endif
        
        int main(void) {
          return lrint ();
        }
Compiler stdout:
 cl : Command line warning D9030 : '/showIncludes' is incompatible with multiprocessing; ignoring /MP switch
testfile.c
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\limits.h
Note: including file:  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\vcruntime.h
Note: including file:   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\sal.h
Note: including file:    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\concurrencysal.h
Note: including file:   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\vadefs.h
E:\vcpkg\clean\vcpkg\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmp0ydnp6qn\testfile.c(10): warning C4391: 'char lrint(void)': incorrect return type for intrinsic function, expected 'long'
E:\vcpkg\clean\vcpkg\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmp0ydnp6qn\testfile.c(10): warning C4392: 'char lrint(void)': incorrect number of arguments for intrinsic function, expected '1' arguments
E:\vcpkg\clean\vcpkg\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmp0ydnp6qn\testfile.c(17): error C2168: 'lrint': too few actual parameters for intrinsic function

@PhoebeHui
Copy link
Contributor Author

Related to upstream issue https://gitlab.gnome.org/GNOME/gdk-pixbuf/-/issues/187.

@PhoebeHui
Copy link
Contributor Author

@Neumann-A, we don't know how to correct the args, we just replace the functions with check code.

@PhoebeHui PhoebeHui marked this pull request as ready for review April 27, 2021 09:36
@JackBoosY JackBoosY added the info:reviewed Pull Request changes follow basic guidelines label Apr 27, 2021
@JackBoosY
Copy link
Contributor

Note this just a workaround to avoid this bug, we need to wait for upstream reply to completely solve this issue.

@Neumann-A
Copy link
Contributor

mesonbuild/meson#8703

@Neumann-A
Copy link
Contributor

Note this just a workaround to avoid this bug, we need to wait for upstream reply to completely solve this issue.

This also happens with autotools and cmake builds. The only difference is that for those we are able to override the result.

@Neumann-A
Copy link
Contributor

I think the trick is to pass /Oi- as an extra compiler argument in the check if msvc is used

@PhoebeHui
Copy link
Contributor Author

I think the trick is to pass /Oi- as an extra compiler argument in the check if msvc is used

It seems related to the option https://docs.microsoft.com/en-us/cpp/build/reference/oi-generate-intrinsic-functions?view=msvc-160.

@Neumann-A
Copy link
Contributor

with if cc.has_function('lrint', dependencies: mathlib_dep, args: '-Oi-')

Running compile:
Working directory:  E:\vcpkg_folders\master\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmpbwbo3a9c
Command line:  C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.28.29910/bin/Hostx64/x64/cl.exe -INCREMENTAL:NO -I"E:/vcpkg_folders/master/installed/x64-windows/include" E:\vcpkg_folders\master\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmpbwbo3a9c\testfile.c /FeE:\vcpkg_folders\master\buildtrees\gdk-pixbuf\x64-windows-rel\meson-private\tmpbwbo3a9c\output.exe /nologo /showIncludes /MD -nologo -DWIN32 -D_WINDOWS -W3 -utf-8 -MP -MD -O2 -Oi -Gy -DNDEBUG -Z7 /nologo /showIncludes /Od kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib -Oi- /link -machine:x64 -DEBUG -OPT:REF -OPT:ICF /LIBPATH:E:/vcpkg_folders/master/installed/x64-windows/lib 

Code:
 
        #define lrint meson_disable_define_of_lrint
        
        #include <limits.h>
        #undef lrint
        
        #ifdef __cplusplus
        extern "C"
        #endif
        char lrint (void);
        
        #if defined __stub_lrint || defined __stub___lrint
        fail fail fail this function is not going to work
        #endif
        
        int main(void) {
          return lrint ();
        }
Compiler stdout:
 cl : Command line warning D9030 : '/showIncludes' is incompatible with multiprocessing; ignoring /MP switch
testfile.c
Note: including file: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\limits.h
Note: including file:  C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\vcruntime.h
Note: including file:   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\sal.h
Note: including file:    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\concurrencysal.h
Note: including file:   C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.28.29910\include\vadefs.h

Compiler stderr:
 cl : Command line warning D9025 : overriding '/O2' with '/Od'
cl : Command line warning D9025 : overriding '/Oi' with '/Oi-'

Checking for function "lrint" with dependency -lm: YES 

@Neumann-A
Copy link
Contributor

this should be the minimal patch. there is no need to patch round
fix_intrinsic.txt

ports/gdk-pixbuf/fix_build_error_windows.patch Outdated Show resolved Hide resolved
ports/gdk-pixbuf/fix_build_error_windows.patch Outdated Show resolved Hide resolved
@PhoebeHui
Copy link
Contributor Author

Thanks @Neumann-A for your help! I applied the minimal patch which pass the option '-Oi' to the check function.

@PhoebeHui PhoebeHui linked an issue Apr 28, 2021 that may be closed by this pull request
@PhoebeHui
Copy link
Contributor Author

With minimal patch, it failed on linux platform:

In file included from ../src/k-pixbuf-2-330a654e51.clean/gdk-pixbuf/pixops/pixops.c:24:0:
../src/k-pixbuf-2-330a654e51.clean/gdk-pixbuf/pixops/../fallback-c89.c:37:1: error: static declaration of ‘lrint’ follows non-static declaration
 lrint (double x)
 ^~~~~
In file included from /usr/include/features.h:424:0,
                 from /usr/include/x86_64-linux-gnu/bits/libc-header-start.h:33,
                 from /usr/include/math.h:27,
                 from ../src/k-pixbuf-2-330a654e51.clean/gdk-pixbuf/pixops/pixops.c:21:
/usr/include/x86_64-linux-gnu/bits/mathcalls.h:314:1: note: previous declaration of ‘lrint’ was here
 __MATHDECL (long int,lrint,, (_Mdouble_ __x));
 ^

@PhoebeHui
Copy link
Contributor Author

@strega-nil-ms, could you help review and merge this PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category:port-bug The issue is with a library, which is something the port should already support info:internal This PR or Issue was filed by the vcpkg team. info:reviewed Pull Request changes follow basic guidelines
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[gdk-pixbuf] build failure
5 participants