libroot_build: *Actually* fix attribute usage on Haiku.
To quote jscipione (from95e8362c52
), "Let me tell you a story about a bug" -- though this tale spans a much lesser time than that one did. In5e19679ea3
, I enabled libroot_build for Haiku, instead of using the system libroot as we had before. There were a number of bugs introduced along with this that I hadn't fixed (and there may be more after this), but most of the obvious ones (crashes on x86_64...) were fixed shortly enough. Attribute usage, though, was a different story. Unlike most of the POSIX calls in libroot, which were aliasing system functions no matter what the platform, the attribute calls were not, as they are specific to Haiku. Initially I had completely forgot about them, and it wasn't until a few days later when I noticed that I had an "attributes" directory in my generated that I realized that the "generic" attribute layer was being used on Haiku. I attempted a fix for this in5e19679ea3
, thinking that would clear the problem up, but I didn't actually run a test beyond seeing that my BuildConfig had been updated properly. In fact, BuildSetup was hard-wired to not even pass that definition through on Haiku, and so that commit had in effect caused nothing. My initial "fix" of just changing BuildSetup then caused a build failure, as while libroot_build itself compiled, it ran into errors whenever attributes were used, because in letting the real libroot's attribute calls shine through, I had bypassed libroot_build's FD emulation/shim layer. Then I tried and failed at three separate attempts to solve this with code: - a version of the "fs_attr_...h" interface for Haiku. This proved possible in theory, but in practice I would need to reimplement a lot of attribute handling code in it, because all I had access to from there was syscalls. - a version of "fs_attr_untyped" that bypassed its reimplementations of the "fs*attr" functions for the libroot ones, only using the FD shim layer. This proved possibly not even theoretically possible because it would have caused preprocessor hell in some of the build headers, and also assumptions about how attributes are read were totally different. - a completely new "fs_attr_haiku" that was a completely new interface to the fs*attr functions. This proved practically impossible because of the need to include structures from the system libroot to call out to readdir, etc. that attempts to solve would also have caused preprocessor hell. Then I realized that the Linux xattr emulation library, which I'd used as a reference when attempting the first solution, was shipped by default as a system library in all builds of Haiku ... and so I could just tell fs_attr_untyped to use the Linux xattr handler, and then link against libgnu. So that is how I arrived at this strange and decidedly unorthodox solution to a problem of my own creation.
This commit is contained in:
parent
e6c08856dd
commit
699b4bbab9
@ -502,29 +502,27 @@ if $(HOST_PLATFORM_BEOS_COMPATIBLE) {
|
||||
# request 64 bit off_t support explicitely.
|
||||
HOST_DEFINES += _GNU_SOURCE _FILE_OFFSET_BITS=64 __STDC_FORMAT_MACROS
|
||||
__STDC_LIMIT_MACROS ;
|
||||
}
|
||||
|
||||
# On Linux with xattr support we can use it for our attribute emulation,
|
||||
# which is somewhat more robust.
|
||||
if $(HAIKU_HOST_USE_XATTR) = 1 {
|
||||
HOST_DEFINES += HAIKU_HOST_USE_XATTR ;
|
||||
} else {
|
||||
# Otherwise the generic attribute emulation is used, which uses a
|
||||
# directory per file to store its attribute. We need to redefine RM so
|
||||
# that the attributes are removed as well. We use a wrapper script,
|
||||
# which invokes a build tool. If the build tool hasn't been built yet,
|
||||
# the normal "rm" is used and the attributes are leaked (likely there
|
||||
# aren't any yet).
|
||||
RM = $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ";"
|
||||
[ FDirName $(HAIKU_TOP) build scripts rm_attrs ]
|
||||
[ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) $(HOST_ARCH) release
|
||||
tools rm_attrs ] -f ;
|
||||
# assumes that rm_attrs is built with debugging disabled
|
||||
HOST_RM_ATTRS_TARGET = <build>rm_attrs ;
|
||||
if $(HAIKU_HOST_USE_XATTR) = 1 {
|
||||
HOST_DEFINES += HAIKU_HOST_USE_XATTR ;
|
||||
} else {
|
||||
# Otherwise the generic attribute emulation is used, which uses a
|
||||
# directory per file to store its attribute. We need to redefine RM so
|
||||
# that the attributes are removed as well. We use a wrapper script,
|
||||
# which invokes a build tool. If the build tool hasn't been built yet,
|
||||
# the normal "rm" is used and the attributes are leaked (likely there
|
||||
# aren't any yet).
|
||||
RM = $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ";"
|
||||
[ FDirName $(HAIKU_TOP) build scripts rm_attrs ]
|
||||
[ FDirName $(HAIKU_OBJECT_DIR) $(HOST_PLATFORM) $(HOST_ARCH) release
|
||||
tools rm_attrs ] -f ;
|
||||
# assumes that rm_attrs is built with debugging disabled
|
||||
HOST_RM_ATTRS_TARGET = <build>rm_attrs ;
|
||||
|
||||
# If specified, use xattr support to tag files with unique IDs.
|
||||
if $(HAIKU_HOST_USE_XATTR_REF) = 1 {
|
||||
HOST_DEFINES += HAIKU_HOST_USE_XATTR_REF ;
|
||||
}
|
||||
# If specified, use xattr support to tag files with unique IDs.
|
||||
if $(HAIKU_HOST_USE_XATTR_REF) = 1 {
|
||||
HOST_DEFINES += HAIKU_HOST_USE_XATTR_REF ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,6 +20,23 @@ typedef struct attr_info {
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/* Since libroot_build is also used on Haiku and linked against the real
|
||||
* libroot which also has the fs*attr functions, these must be shadowed. */
|
||||
#define fs_read_attr build_fs_read_attr
|
||||
#define fs_write_attr build_fs_write_attr
|
||||
#define fs_remove_attr build_fs_remove_attr
|
||||
#define fs_stat_attr build_fs_stat_attr
|
||||
#define fs_open_attr build_fs_open_attr
|
||||
#define fs_fopen_attr build_fs_fopen_attr
|
||||
#define fs_close_attr build_fs_close_attr
|
||||
#define fs_open_attr_dir build_fs_open_attr_dir
|
||||
#define fs_fopen_attr_dir build_fs_fopen_attr_dir
|
||||
#define fs_close_attr_dir build_fs_close_attr_dir
|
||||
#define fs_read_attr_dir build_fs_read_attr_dir
|
||||
#define fs_rewind_attr_dir build_fs_rewind_attr_dir
|
||||
|
||||
|
||||
extern ssize_t fs_read_attr(int fd, const char *attribute, uint32 type,
|
||||
off_t pos, void *buffer, size_t readBytes);
|
||||
extern ssize_t fs_write_attr(int fd, const char *attribute, uint32 type,
|
||||
|
@ -78,10 +78,15 @@ local librootSources =
|
||||
|
||||
USES_BE_API on [ FGristFiles $(librootSources:S=$(SUFOBJ)) ] = true ;
|
||||
|
||||
local extraLibs ;
|
||||
if $(HOST_PLATFORM) = haiku_host {
|
||||
extraLibs = gnu ;
|
||||
}
|
||||
|
||||
BuildPlatformSharedLibrary libroot_build.so :
|
||||
$(librootSources)
|
||||
:
|
||||
$(HOST_LIBSUPC++) $(HOST_LIBSTDC++)
|
||||
$(HOST_LIBSUPC++) $(HOST_LIBSTDC++) $(extraLibs)
|
||||
;
|
||||
|
||||
# TODO: This doesn't work with the function remapping.
|
||||
|
@ -1,9 +1,5 @@
|
||||
#ifdef HAIKU_HOST_USE_XATTR
|
||||
# ifdef HAIKU_HOST_PLATFORM_HAIKU
|
||||
// Do nothing; we allow libroot's fs_attr symbols to shine through.
|
||||
# else
|
||||
# include "fs_attr_untyped.cpp"
|
||||
# endif
|
||||
#else
|
||||
# include "fs_attr_generic.cpp"
|
||||
#endif
|
||||
#ifdef HAIKU_HOST_USE_XATTR
|
||||
# include "fs_attr_untyped.cpp"
|
||||
#else
|
||||
# include "fs_attr_generic.cpp"
|
||||
#endif
|
||||
|
@ -39,7 +39,7 @@
|
||||
|
||||
|
||||
// Include the interface to the host platform attributes support.
|
||||
#if defined(HAIKU_HOST_PLATFORM_LINUX)
|
||||
#if defined(HAIKU_HOST_PLATFORM_LINUX) || defined(HAIKU_HOST_PLATFORM_HAIKU)
|
||||
# include "fs_attr_xattr.h"
|
||||
#elif defined(HAIKU_HOST_PLATFORM_FREEBSD)
|
||||
# include "fs_attr_extattr.h"
|
||||
|
Loading…
Reference in New Issue
Block a user