mirror of
https://git.sr.ht/~cismonx/bookmarkfs
synced 2025-06-07 19:58:50 +00:00
all: better workaround for __FILE_NAME__
There's only a few legacy releases of gcc and clang that support -fmacro-prefix-map but not __FILE_NAME__. Thus the originial workaround is not very beneficial. Switching to a more portable `__FILE__ + offset` workaround that works for any standard-compliant compiler, even TinyCC. However, this workaround may produce binaries that leak information about the build environment, especially when using an exotic build path.
This commit is contained in:
parent
5286cda051
commit
c17d6ebadf
3 changed files with 8 additions and 15 deletions
10
configure.ac
10
configure.ac
|
@ -198,17 +198,11 @@ AC_COMPILE_IFELSE([
|
|||
AC_LANG_SOURCE([[char const *name = __FILE_NAME__;]])
|
||||
], [
|
||||
AC_MSG_RESULT([yes])
|
||||
AS_VAR_SET([no_file_name], [no])
|
||||
], [
|
||||
AC_MSG_RESULT([no])
|
||||
AX_CHECK_COMPILE_FLAG([-fmacro-prefix-map==], [
|
||||
AS_VAR_SET([macro_prefix_map], [yes])
|
||||
], [
|
||||
AC_MSG_WARN(m4_normalize([
|
||||
The `-fmacro-prefix-map' preprocessor flag is not supported.
|
||||
]))
|
||||
])
|
||||
])
|
||||
AM_CONDITIONAL([MACRO_PREFIX_MAP], [test x${macro_prefix_map} != xno])
|
||||
AM_CONDITIONAL([NO_FILE_NAME], [test x${no_file_name} != xno])
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
AS_VAR_IF([ac_have_largefile], [no], [
|
||||
|
|
|
@ -14,9 +14,9 @@ lib_LTLIBRARIES =
|
|||
pkglib_LTLIBRARIES =
|
||||
|
||||
BASE_CPPFLAGS_ = -DBUILDING_BOOKMARKFS
|
||||
if MACRO_PREFIX_MAP
|
||||
BASE_CPPFLAGS_ += -fmacro-prefix-map=$(srcdir)/=
|
||||
endif # MACRO_PREFIX_MAP
|
||||
if NO_FILE_NAME
|
||||
BASE_CPPFLAGS_ += -DBOOKMARKFS_SRCDIR=\"$(srcdir)\"
|
||||
endif # NO_FILE_NAME
|
||||
|
||||
MODULE_CFLAGS_ =
|
||||
if HIDE_MODULE_SYMBOLS
|
||||
|
@ -55,7 +55,8 @@ endif # BOOKMARKFS_UTIL
|
|||
if BOOKMARKCTL
|
||||
bin_PROGRAMS += bookmarkctl
|
||||
|
||||
bookmarkctl_SOURCES = bookmarkctl.c fsck_util.c
|
||||
bookmarkctl_CPPFLAGS = $(BASE_CPPFLAGS_)
|
||||
bookmarkctl_SOURCES = bookmarkctl.c fsck_util.c
|
||||
endif # BOOKMARKCTL
|
||||
|
||||
if BOOKMARKFS_FSCK
|
||||
|
|
|
@ -114,9 +114,7 @@
|
|||
#ifdef __FILE_NAME__
|
||||
# define FILE_NAME_ __FILE_NAME__
|
||||
#else
|
||||
// NOTE: Using __FILE__ may produce ugly logs and break reproducible build.
|
||||
// Workaround with `-fmacro-prefix-map=${srcdir}/=` CPPFLAGS.
|
||||
# define FILE_NAME_ __FILE__
|
||||
# define FILE_NAME_ ( __FILE__ + sizeof(BOOKMARKFS_SRCDIR) )
|
||||
#endif
|
||||
|
||||
#define BOOKMARKFS_HOMEPAGE_URL "https://nongnu.org/bookmarkfs"
|
||||
|
|
Loading…
Add table
Reference in a new issue