From 1c3269629a6dd61ba6b78a24641d6821567bbf82 Mon Sep 17 00:00:00 2001 From: Samuel Thibault Date: Wed, 28 May 2008 00:54:52 +0100 Subject: porting explanations from the thread 'Analysis of build failures in Debian GNU/Hurd' --- unsorted/PortingIssues.mdwn | 89 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 10 deletions(-) (limited to 'unsorted') diff --git a/unsorted/PortingIssues.mdwn b/unsorted/PortingIssues.mdwn index 747fb230..993d4843 100644 --- a/unsorted/PortingIssues.mdwn +++ b/unsorted/PortingIssues.mdwn @@ -53,6 +53,10 @@ If you get Bad File Descriptor error when trying to read from a file (or accessi Every unconditionalized use of `PATH_MAX`, `MAX_PATH` or `MAXPATHLEN` is a POSIX incompatibility. If there is no upper limit on the length of a path (as its the case for GNU), this symbol is not defined in any header file. Instead, you need to either use a different implementation that does not rely on the length of a string or use `sysconf()` to query the length at runtime. If `sysconf()` returns -1, you have to use `realloc()` to allocate the needed memory dynamically. +## `ARG_MAX` + +Same as `PATH_MAX`. There is no limit on the number of arguments. + ## `MAXHOSTNAMELEN` Same as `PATH_MAX`. When you find a `gethostname()` function, which acts on a static buffer, you can replace it with Neal's [xgethostname function](http://ftp.walfield.org/pub/people/neal/xgethostname/) which returns the hostname as a dynamic buffer. For example: @@ -81,7 +85,7 @@ Fixed code: ## `NOFILE` -Replace with `RLIMIT_NOFILE` +Replace with `getrlimit(RLIMIT_NOFILE,...)` ## GNU specific `#define` @@ -137,27 +141,92 @@ Those are evil if they don't exist and you want to name a directory this way. Fo Change it to use `termios.h` (check for it properly with autoconf `HAVE_TERMIOS_H` or the `__GLIBC__` macro) +Also, change calls to `ioctl(fd, TCGETS, ...)` and `ioctl(fd, TCSETS, ...)` with `tcgetattr(fd, ...)` and `tcsetattr(fd, ...)`. + ## `AC_HEADER_TERMIO` The autoconf check for `AC_HEADER_TERMIO` tryes to check for termios, but it's only really checking for termio in `termios.h`. It is better to use `AC_CHECK_HEADERS(termio.h termios.h)` -## broken libc6 dependency +## missing `_IOT` -Some packages use an erroneous dependency on `libc6-dev`. This is incorrect because `libc6` is specific to GNU/Linux. The corresponding package for GNU is `libc0.3-dev` but other OSes will have different ones. You can locate the problem in the `debian/control` file of the source tree. Typical solutions include detecting the OS using `dpkg-architecture` and hardcoding the soname, or better, use a logical OR. eg: `libc6-dev | libc0.3-dev | libc-dev`. The `libc-dev` is a virtual package that works for any soname but you have to put it only as the last option. +This comes from ioctls. Fixing this is easy if the structure members can be expressed by using the _IOT() macro, else it's simply impossible... See `bits/termios.h` for an instance: + +`#define _IOT_termios /* Hurd ioctl type field. */ \ + _IOT (_IOTS (tcflag_t), 4, _IOTS (cc_t), NCCS, _IOTS (speed_t), 2)` + +because `struct termios` holds 4 members of type `tcflag_ts`, then `NCCS` +members of type `cc_tsi` and finaly 2 members of type `speed_ts`. + +As you can see, this limits the number of kinds of members to 3, and in +addition to that (see the bitfield described in `ioctls.h`), the third +kind of member is limited to 3 members. However, since at the API +compatibility layer you are generally allowed to reorder fields in +structures, you can usually manage to fit into these limits. + +Note: if a field member is a pointer, then the ioctl can't be expressed +this way, and that makes sense, since the server you're talking to +doesn't have direct access to your memory. Ways other than ioctls must +then be found. + +## `SA_SIGINFO` + +Not implemented, packages may be fixed for working around this: use void sighandler(int num) prototype and sa_handler field. + +## `MSG_NOSIGNAL` + +Not implemented yet: [Savannah bug](https://savannah.gnu.org/bugs/?18218) + +## `IPV6_PKTINFO` + +Not fixed yet: [Glibc bug](http://sourceware.org/bugzilla/show_bug.cgi?id=3906) + +## `SOL_IP` + +Not implemented yet. -## Third argument in `ioctl` (`TIOCFLUSH`, etc) +## `HZ` -Broken arguments for `ioctl`'s which might work on other systems will cause segfault on GNU, because they are passed to and from a Hurd server RPC. +Linuxish and doesn't even make sense since the value may vary according to the running kernel. Should use `sysconf(_SC_CLK_TCK)` or `CLK_TCK` instead. -For example, `TIOCFLUSH` wants an `(int *)`, but will run on GNU/Linux if you pass it a 0. The solution in this case is to declare and assign an `int`, eg: +## `SIOCDEVPRIVATE` - int out = 0; +Oh, we should probably provide it. -and pass its address to `ioctl`: +## `MAP_NORESERVE` - ioctl (fd, TIOCFLUSH, &out); +Not POSIX, but we could implement it. -See [a simple fix for TIOCFLUSH in telnet](http://mail.gnu.org/archive/html/bug-inetutils/2001-08/msg00015.html). +## `O_DIRECT` + +Long story to implement. + +## `PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP` + +We could easily provide it; + +## `PTHREAD_STACK_MIN` + +We should actually provide it. + +## `linux/types.h` or `asm/types.h` + +These are not POSIX, `sys/types.h` and `stdint.h` should be used instead. + +## `iopl` + +Not supported. Try to replace with `ioperm(0, 65536, 1)` (conditionned with `__GNU__` as that will not work in Linux). + +## `semget`, `sem_open` + +Not implemented, will always fail. Use `sem_init()` instead if possible. + +## `net/if_arp.h`, `net/ethernet.h`, etc. + +Not implemented, not POSIX. Try to disable the feature in the package. + +## broken libc6 dependency + +Some packages use an erroneous dependency on `libc6-dev`. This is incorrect because `libc6` is specific to GNU/Linux. The corresponding package for GNU is `libc0.3-dev` but other OSes will have different ones. You can locate the problem in the `debian/control` file of the source tree. Typical solutions include detecting the OS using `dpkg-architecture` and hardcoding the soname, or better, use a logical OR. eg: `libc6-dev | libc0.3-dev | libc-dev`. The `libc-dev` is a virtual package that works for any soname but you have to put it only as the last option. ---- -- cgit v1.2.3