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

Rename generated version header to avoid conflict on case insensitive filesystems #1927

Closed
wants to merge 1 commit into from

Conversation

DDRBoxman
Copy link
Contributor

@DDRBoxman DDRBoxman commented Dec 20, 2023

On macOS the compiler was not correctly choosing between the Version.h header from MPD or the version.h header in mpdclient.

@DDRBoxman DDRBoxman force-pushed the version branch 4 times, most recently from ccb2210 to b682ea0 Compare December 20, 2023 18:15
@MaxKellermann
Copy link
Member

How can there be a conflict? These are in different directories, and libmpdclient's version.h isn't even in the search path - it's below "mpd/".

@DDRBoxman
Copy link
Contributor Author

This is the error I'm seeing after the updates to master this morning

In file included from ../../src/db/plugins/ProxyDatabasePlugin.cxx:31:
../../subprojects/libmpdclient/include/mpd/client.h:84:10: warning: non-portable path to file '"Version.h"'; specified path differs in case from file name on disk [-Wnonportable-include-path]
#include "version.h"
         ^~~~~~~~~~~
         "Version.h"
../../src/db/plugins/ProxyDatabasePlugin.cxx:169:5: error: function-like macro 'LIBMPDCLIENT_CHECK_VERSION' is not defined
#if LIBMPDCLIENT_CHECK_VERSION(2,17,0)
    ^
../../src/db/plugins/ProxyDatabasePlugin.cxx:176:5: error: function-like macro 'LIBMPDCLIENT_CHECK_VERSION' is not defined
#if LIBMPDCLIENT_CHECK_VERSION(2,20,0)
    ^
../../src/db/plugins/ProxyDatabasePlugin.cxx:183:5: error: function-like macro 'LIBMPDCLIENT_CHECK_VERSION' is not defined
#if LIBMPDCLIENT_CHECK_VERSION(2,21,0)
    ^
../../src/db/plugins/ProxyDatabasePlugin.cxx:212:5: error: function-like macro 'LIBMPDCLIENT_CHECK_VERSION' is not defined
#if LIBMPDCLIENT_CHECK_VERSION(2,21,0)
    ^
../../src/db/plugins/ProxyDatabasePlugin.cxx:336:5: error: function-like macro 'LIBMPDCLIENT_CHECK_VERSION' is not defined
#if LIBMPDCLIENT_CHECK_VERSION(2,21,0)
    ^
../../src/db/plugins/ProxyDatabasePlugin.cxx:823:5: error: function-like macro 'LIBMPDCLIENT_CHECK_VERSION' is not defined
#if LIBMPDCLIENT_CHECK_VERSION(2,21,0)
    ^
1 warning and 6 errors generated.

… filesystems

On macOS the compiler was not correctly choosing between the Version.h header from MPD
or the version.h header in mpdclient.
@MaxKellermann
Copy link
Member

Okay, I see, that's because libmpdclient is not installed, so version.h is not in the same directory as client.h, and your compiler flags happen to be in this order. But there must be a better way to fix this; your solution is too fragile, it just makes the symptom go away, but doesn't really solve the general problem.
This is the bad commit in libmpdclient, me trying to solve a subproject problem but not properly: MusicPlayerDaemon/libmpdclient@d8b10bb63

MaxKellermann added a commit to MusicPlayerDaemon/libmpdclient that referenced this pull request Dec 22, 2023
This fixes a "version.h" conflict when used as a Meson subproject:
when the parent project also generates a "version.h", it is not clear
which one will be included.  We solve this by requiring the "mpd/"
prefix for libmpdclient.

See MusicPlayerDaemon/MPD#1927
@MaxKellermann
Copy link
Member

I implemented a better solution which avoids the conflict completely instead of sidestepping it with a different filename.

@DDRBoxman
Copy link
Contributor Author

Hmm, just checked out master and I'm still running into the import conflict 🤔

@MaxKellermann
Copy link
Member

Is there a version.h leftover from the previous build? Did you rebuild from scratch?

@DDRBoxman
Copy link
Contributor Author

I deleted the output folder and ran from scratch, yeah.

Updated to the latest master again and now it seems that id3 is mad too

In file included from ../../src/tag/FixString.cxx:4:
In file included from ../../src/tag/FixString.hxx:7:
In file included from /Users/ddrboxman/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/c++/v1/string_view:205:
In file included from /Users/ddrboxman/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/c++/v1/__algorithm/min.h:13:
In file included from /Users/ddrboxman/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/c++/v1/__algorithm/comp_ref_type.h:13:
In file included from /Users/ddrboxman/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/c++/v1/__debug:16:
In file included from /Users/ddrboxman/Library/Android/sdk/ndk/26.1.10909125/toolchains/llvm/prebuilt/darwin-x86_64/bin/../sysroot/usr/include/c++/v1/cstddef:41:
../../subprojects/libid3tag-0.15.1b/version:1:1: error: expected unqualified-id
0.15.1b
^

@DDRBoxman
Copy link
Contributor Author

Ah, yeah definitely the same include path leaking issue there too

@DDRBoxman
Copy link
Contributor Author

libid3tag_dep = declare_dependency(
  link_with: libid3tag,
  include_directories: include_directories('.'),
)

Going to try to be more explicit with that include_directories export and see if that fixes the id3 issue

@DDRBoxman
Copy link
Contributor Author

Not sure where the i3dtag wrap file comes from but this does the trick, and lets me build the whole project.

fs = import('fs')

project(
  'libid3tag', 'c',
  version: '0.15.1b',
  license: 'GPLv2+',
)

compiler = meson.get_compiler('c')

conf = configuration_data()
conf.set('HAVE_ASSERT_H', true)
conf.set('HAVE_FTRUNCATE', compiler.has_function('ftruncate'))
conf.set('HAVE_INTTYPES_H', true)
conf.set('HAVE_LIBZ', false) # TODO
conf.set('HAVE_STDINT_H', true)
conf.set('HAVE_STDIO_H', true)
conf.set('HAVE_STDLIB_H', true)
conf.set('HAVE_STRINGS_H', true)
conf.set('HAVE_STRING_H', true)
conf.set('HAVE_SYS_STAT_H', compiler.has_header('sys/stat.h'))
conf.set('HAVE_SYS_TYPES_H', true)
conf.set('HAVE_UNISTD_H', compiler.has_header('unistd.h'))
configure_file(output: 'config.h', configuration: conf)

add_project_arguments('-DHAVE_CONFIG_H', language: 'c')

libid3tag = static_library(
  'id3tag',
  'version.c', 'ucs4.c', 'latin1.c', 'utf16.c', 'utf8.c',
  'parse.c', 'render.c', 'field.c', 'frametype.c', 'compat.c',
  'genre.c', 'frame.c', 'crc.c', 'util.c', 'tag.c', 'file.c',
)

copy = fs.copyfile('id3tag.h', 'include/id3tag.h')

libid3tag_dep = declare_dependency(
  link_with: libid3tag,
  dependencies: [copy]
  include_directories: include_directories('include'),
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants