View Issue Details

IDProjectCategoryView StatusLast Update
0009703ardourbugspublic2024-05-08 02:17
Reporterccaudle Assigned To 
PrioritylowSeverityblockReproducibilityalways
Status newResolutionreopened 
Platformx86_64OSFedora gnu/linuxOS Version40
Product Version8.6 
Summary0009703: latest fedora toolchain breaksk compilation
DescriptionOn Fedora 40 git head no longer compiles:

In file included from ../libs/tk/ytk/gtkrc.c:44:
../libs/tk/ytk/gtkrc.c: In function ‘gtk_rc_context_parse_one_file’:
/usr/include/glib-2.0/glib/gstdio.h:78:19: error: implicit declaration of function ‘lstat’; did you mean ‘fstat’? [-Wimplicit-function-declaration]
   78 | #define g_lstat lstat
      | ^~~~~
../libs/tk/ytk/gtkrc.c:790:8: note: in expansion of macro ‘g_lstat’
  790 | if (!g_lstat (rc_file->canonical_name, &statbuf))
      | ^~~~~~~

Steps To ReproduceUpdate to Fedora 40 which includes gcc-14.0.1-0.15
git pull, attempt to ./waf

Configure command used:
./waf configure --libjack=weak --with-backends=jack,alsa,dummy --cxx11 --strict


Additional InformationThe cause of the error information is not obvious. I have not yet tried building a small test application to see if the problem occurs using all system files.
My first suspicion is that having a mixed build using the Ardour reduced GTK, but still having system GTK headers installed, may cause some conflict, but I do not see immediately how to address that.

Line 44 of gtkrc.c is:
#include <glib/gstdio.h>

gstdio.h includes <sys/stat.h> and has this in line 78:
#define g_lstat lstat

stat.h has lstat defined using a few layers of #ifdef:

#if defined __USE_XOPEN_EXTENDED || defined __USE_XOPEN2K
# ifndef __USE_FILE_OFFSET64
/* Get file attributes about FILE and put them in BUF.
   If FILE is a symbolic link, do not follow it. */
extern int lstat (const char *__restrict __file,
                  struct stat *__restrict __buf) __THROW __nonnull ((1, 2));
# else
# ifdef __USE_TIME_BITS64
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (lstat,
                           (const char *__restrict __file,
                            struct stat *__restrict __buf), __lstat64_time64)
     __nonnull ((1, 2));
# else
# define lstat __lstat64_time64
# endif
# else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (lstat,
                           (const char *__restrict __file,
                            struct stat *__restrict __buf), lstat64)
     __nonnull ((1, 2));
# else
# define lstat lstat64
# endif
# endif
# endif
# ifdef __USE_LARGEFILE64
# ifndef __USE_TIME_BITS64
extern int lstat64 (const char *__restrict __file,
                    struct stat64 *__restrict __buf)
     __THROW __nonnull ((1, 2));
# else
extern int __REDIRECT_NTH (lstat64, (const char *__restrict __file,
                                     struct stat64 *__restrict __buf),
                           __lstat64_time64)
     __nonnull ((1, 2));
# endif
# endif
#endif
TagsNo tags attached.

Activities

x42

2024-05-05 02:10

administrator   ~0028710

Can you try if attached patch helps? Thanks in advance.
fix_9703.diff (1,174 bytes)   
diff --git a/libs/tk/ytk/wscript b/libs/tk/ytk/wscript
index 11721244d1..63e1c2afc5 100644
--- a/libs/tk/ytk/wscript
+++ b/libs/tk/ytk/wscript
@@ -282,7 +282,7 @@ def build(bld):
     obj.uselib          = 'GLIB GIO PANGO CAIRO PANGOCAIRO GMODULE'
     obj.defines         = [ 'HAVE_CONFIG_H', '_LARGEFILE64_SOURCE', '_REENTRANT', 'G_LOG_DOMAIN="Gtk"', 'GTK_COMPILATION', '_FILE_OFFSET_BITS=64', 'GTK_DISABLE_DEPRECATED', 'G_DISABLE_CAST_CHECKS',
                             'G_DISABLE_SINGLE_INCLUDES', 'DATK_DISABLE_SINGLE_INCLUDES', 'GDK_PIXBUF_DISABLE_SINGLE_INCLUDES', 'GTK_DISABLE_SINGLE_INCLUDES', 'GDK_PIXBUF_DISABLE_DEPRECATED',
-                            'GTK_PRINT_BACKENDS="file,lpr"', 'GTK_PRINT_BACKEND_ENABLE_UNSUPPORTED', 'GTK_PRINT_PREVIEW_COMMAND=""',
+                            'GTK_PRINT_BACKENDS="file,lpr"', 'GTK_PRINT_BACKEND_ENABLE_UNSUPPORTED', 'GTK_PRINT_PREVIEW_COMMAND=""', '_POSIX_C_SOURCE=200809L',
                             'GTK_VERSION="2.24.23"', 'GTK_BINARY_VERSION="2.10.0"', 'GTK_HOST="ardour"',
                             'PACKAGE="' + I18N_PACKAGE + '"',
                             'GETTEXT_PACKAGE="' + I18N_PACKAGE + '"',
fix_9703.diff (1,174 bytes)   

kiilerix

2024-05-06 16:29

reporter   ~0028719

I had https://github.com/Ardour/ardour/pull/893 which I think will solve the problem too.

The patch from x42 might also work and be a more general solution that would allow cleanup of many other #defines. But I haven't tested it yet.

x42

2024-05-06 22:25

administrator   ~0028720

Fixed in Ardour 8.6-101-g4b8b5acfc4 Please test

ccaudle

2024-05-07 21:24

reporter   ~0028722

The patch and also the latest git changes corrected the original problem, but exposed this additional similar problem:
../libs/aaf/utils.c: In function ‘laaf_util_absolute_path’:
../libs/aaf/utils.c:426:14: error: implicit declaration of function ‘realpath’ [-Wimplicit-function-declaration]
  426 | if (!realpath (relpath, buf)) {
      | ^~~~~~~~

I found that realpath() is in stdlib.h, but is conditional on #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED.
The features.h file describes __USE_MISC as for "things from 4.3BSD or System V Unix," and sets __USE_MISC if _DEFAULT_SOURCE is defined.

I don't see anything in the gcc release notes or "porting to gcc 14" page that indicates these are new, but the release notes do indicate that implicit function declaration is strictly checked now.
With previous gcc was it the case that the header prototype was never actually included because an appropriate #define was not set, but the linker was able to find the function anyway? I can't see what else would have changed to make this visible now.
Is that #define _DEFAULT_SOURCE something that should be in an ardour header, or generated by waf? Or something else is the correct solution?

x42

2024-05-07 21:41

administrator   ~0028723

That make me wonder how `libs/pbd/file_utils.cc` compiles (that also uses realpath)

x42

2024-05-07 21:45

administrator   ~0028724

From realpath (3)
       realpath():
           _XOPEN_SOURCE >= 500
               || /* Glibc since 2.19: */ _DEFAULT_SOURCE
               || /* Glibc versions <= 2.19: */ _BSD_SOURCE


https://www.gnu.org/software/libc/manual/html_node/Feature-Test-Macros.html


_XOPEN_SOURCE or _POSIX_C_SOURCE seem preferable

kiilerix

2024-05-07 23:00

reporter   ~0028725

realpath works in c++ because it always sets _GNU_SOURCE uses it for any `extern "C"`. It is thus a bit futile to discuss what flags to use for bare C files.

$ echo | g++ -dM -E -x c++ - | grep GNU_SOURCE
#define _GNU_SOURCE 1

FWIW, it was fixed for C in https://github.com/Ardour/ardour/pull/893/files#diff-0f65f79362b8a4f80bf8b0040aed6213610d1f3e58eac0699e45417a84ce620eR21 . But a more restricted but cross platform `#define _XOPEN_SOURCE 500` works too.

x42

2024-05-07 23:26

administrator   ~0028726

> $ echo | g++ -dM -E -x c++ - | grep GNU_SOURCE

does not include `GNU_SOURCE on macOS (and also not *BSD).

ccaudle

2024-05-08 02:17

reporter   ~0028727

That pull 893 from kiilerix fixes the problems I have seen.

Issue History

Date Modified Username Field Change
2024-05-04 23:13 ccaudle New Issue
2024-05-05 02:10 x42 Note Added: 0028710
2024-05-05 02:10 x42 File Added: fix_9703.diff
2024-05-06 16:29 kiilerix Note Added: 0028719
2024-05-06 22:25 x42 Assigned To => x42
2024-05-06 22:25 x42 Status new => resolved
2024-05-06 22:25 x42 Resolution open => fixed
2024-05-06 22:25 x42 Note Added: 0028720
2024-05-07 21:24 ccaudle Note Added: 0028722
2024-05-07 21:41 x42 Note Added: 0028723
2024-05-07 21:41 x42 Assigned To x42 =>
2024-05-07 21:41 x42 Status resolved => new
2024-05-07 21:41 x42 Resolution fixed => reopened
2024-05-07 21:45 x42 Note Added: 0028724
2024-05-07 23:00 kiilerix Note Added: 0028725
2024-05-07 23:26 x42 Note Added: 0028726
2024-05-08 02:17 ccaudle Note Added: 0028727