Opened 3 years ago

Last modified 3 years ago

#62498 assigned defect

meson: other ports can't build universal

Reported by: ryandesign (Ryan Carsten Schmidt) Owned by: git@…
Priority: Normal Milestone:
Component: ports Version: 2.6.99
Keywords: Cc: kencu (Ken)
Port: meson

Description

babl @0.1.82_0 can't build with the universal variant on macOS High Sierra:

:info:build ../babl-0.1.82/babl/babl-extension.c:201:3: error: use of undeclared identifier 'HLIB'
:info:build   HLIB  dl_handle = NULL;
:info:build   ^
:info:build ../babl-0.1.82/babl/babl-extension.c:206:3: error: use of undeclared identifier 'dl_handle'
:info:build   dl_handle = dlopen (path, RTLD_NOW);
:info:build   ^
:info:build ../babl-0.1.82/babl/babl-extension.c:206:15: error: implicit declaration of function 'dlopen' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build   dl_handle = dlopen (path, RTLD_NOW);
:info:build               ^
:info:build ../babl-0.1.82/babl/babl-extension.c:207:8: error: use of undeclared identifier 'dl_handle'
:info:build   if (!dl_handle)
:info:build        ^
:info:build ../babl-0.1.82/babl/babl-extension.c:209:43: error: implicit declaration of function 'dlerror' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build       babl_log ("dlopen() failed:\n\t%s", dlerror ());
:info:build                                           ^
:info:build ../babl-0.1.82/babl/babl-extension.c:212:34: error: implicit declaration of function 'dlsym' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build   init = (BablExtensionInitFunc) dlsym (dl_handle, "init");
:info:build                                  ^
:info:build ../babl-0.1.82/babl/babl-extension.c:212:41: error: use of undeclared identifier 'dl_handle'
:info:build   init = (BablExtensionInitFunc) dlsym (dl_handle, "init");
:info:build                                         ^
:info:build ../babl-0.1.82/babl/babl-extension.c:216:7: error: implicit declaration of function 'dlclose' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
:info:build       dlclose (dl_handle);
:info:build       ^
:info:build ../babl-0.1.82/babl/babl-extension.c:216:16: error: use of undeclared identifier 'dl_handle'
:info:build       dlclose (dl_handle);
:info:build                ^
:info:build ../babl-0.1.82/babl/babl-extension.c:220:47: error: use of undeclared identifier 'dl_handle'
:info:build   destroy = (BablExtensionDestroyFunc) dlsym (dl_handle, "destroy");
:info:build                                               ^
:info:build ../babl-0.1.82/babl/babl-extension.c:222:28: error: use of undeclared identifier 'dl_handle'
:info:build                            dl_handle,
:info:build                            ^
:info:build ../babl-0.1.82/babl/babl-extension.c:229:16: error: use of undeclared identifier 'dl_handle'
:info:build       dlclose (dl_handle);
:info:build                ^
:info:build 12 errors generated.

I believe the reason why these things cannot be found is that the right header has not been included because meson incorrectly determined that the header did not exist:

:info:configure Has header "stdatomic.h" : NO 
:info:configure Has header "dlfcn.h" : NO 

The reason why meson didn't detect these headers is that it incorrectly used -arch flags when doing so: from meson-log.txt:

Running compile:
Working directory:  /opt/local/var/macports/build/_Users_rschmidt_macports_macports-ports-ryandesign-fork_graphics_babl/babl/work/build/meson-private/tmpoi5rwtan
Command line:  ccache /usr/bin/clang -I/opt/local/include /opt/local/var/macports/build/_Users_rschmidt_macports_macports-ports-ryandesign-fork_graphics_babl/babl/work/build/meson-private/tmpoi5rwtan/testfile.c -pipe -E -P -Os -Werror=implicit-function-declaration -arch x86_64 -arch i386 -P -O0 

Code:
 
        #ifdef __has_include
         #if !__has_include("dlfcn.h")
          #error "Header 'dlfcn.h' could not be found"
         #endif
        #else
         #include <dlfcn.h>
        #endif
Compiler stdout:
 
Compiler stderr:
 clang: error: cannot use 'cpp-output' output with multiple -arch options

Has header "dlfcn.h" : NO 

I believe it is a defect in meson that it is using -arch flags for these tests. autoconf does not have this defect.

When not building universal, the configure output is:

Has header "stdatomic.h" : YES
Has header "dlfcn.h" : YES

and the build succeeds.

P.S: @SoapZA please log in to MacPorts Trac so that your GitHub handle is available for auto-completion in the assignment and Cc fields.

Change History (3)

comment:1 Changed 3 years ago by kencu (Ken)

Known issue with meson, may or may not ever be fixed upstream. They are aware, Jeremy opened an issue months ago about this.

For now, you’re in luck that I at least made the muniversal PG work correctly.

That may be all we ever get for this, but time will tell.

comment:2 Changed 3 years ago by ryandesign (Ryan Carsten Schmidt)

So the meson portgroup should include the muniversal portgroup so that all meson-using ports are fixed? or what?

comment:3 Changed 3 years ago by kencu (Ken)

I am not at this point able to say if every port that builds with meson cannot build universal without the muniversal PG. It might be so, but I haven't verified that.

Jeremy's upstream issue <https://github.com/mesonbuild/meson/issues/8206>.

Note: See TracTickets for help on using tickets.