I'm trying to build libiconv as a static library for a Cortex M4 using the GNU ARM Toolchain and it seems the process is mostly successful.
I configure libiconv thus:
./configure --build=x86_64-linux-gnu --host=arm-none-eabi --prefix=/home/josaphat/Downloads/libiconv-1.14/build_dir CFLAGS="-nostdlib -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard" --enable-static
Configure doesn't show any warnings or errors that I can discern other than "WARNING: using cross tools not prefixed with host triplet" (but it finds and uses the correct compiler just fine so I figure I can safely ignore this).
The errors come when compiling sigprogmask.c
:
[... snip ...]
arm-none-eabi-gcc -DHAVE_CONFIG_H -DEXEEXT=\"\" -I. -I.. -I../lib -I../intl -DDEPENDS_ON_LIBICONV=1 -DDEPENDS_ON_LIBINTL=1 -nostdlib -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mthumb -mfloat-abi=hard -c sigprocmask.c
In file included from /usr/local/gcc-arm-none-eabi-4_8-2014q2/arm-none-eabi/include/signal.h:5:0,
from ./signal.h:52,
from sigprocmask.c:44:
./signal.h:490:1: error: expected identifier or '(' before 'const'
_GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
^
./signal.h:490:1: error: expected ')' before '&' token
_GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
^
./signal.h:490:1: error: expected ')' before '!=' token
_GL_FUNCDECL_SYS (sigismember, int, (const sigset_t *set, int sig)
^
./signal.h:503:1: error: expected ')' before '*' token
_GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
^
./signal.h:503:1: error: expected ')' before '=' token
_GL_FUNCDECL_SYS (sigemptyset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
^
./signal.h:515:1: error: expected ')' before '*' token
_GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig)
^
./signal.h:515:1: error: expected ')' before '|=' token
_GL_FUNCDECL_SYS (sigaddset, int, (sigset_t *set, int sig)
^
./signal.h:528:1: error: expected ')' before '*' token
_GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig)
^
./signal.h:528:1: error: expected ')' before '&=' token
_GL_FUNCDECL_SYS (sigdelset, int, (sigset_t *set, int sig)
^
./signal.h:541:1: error: expected ')' before '*' token
_GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
^
./signal.h:541:1: error: expected ')' before '=' token
_GL_FUNCDECL_SYS (sigfillset, int, (sigset_t *set) _GL_ARG_NONNULL ((1)));
^
sigprocmask.c:87:14: error: expected identifier or '(' before 'const'
sigismember (const sigset_t *set, int sig)
^
sigprocmask.c:87:1: error: expected ')' before '&' token
sigismember (const sigset_t *set, int sig)
^
sigprocmask.c:87:1: error: expected ')' before '!=' token
sigismember (const sigset_t *set, int sig)
^
sigprocmask.c:103:23: error: expected ')' before '*' token
sigemptyset (sigset_t *set)
^
sigprocmask.c:103:1: error: expected ')' before '=' token
sigemptyset (sigset_t *set)
^
sigprocmask.c:110:21: error: expected ')' before '*' token
sigaddset (sigset_t *set, int sig)
^
sigprocmask.c:110:1: error: expected ')' before '|=' token
sigaddset (sigset_t *set, int sig)
^
sigprocmask.c:130:21: error: expected ')' before '*' token
sigdelset (sigset_t *set, int sig)
^
sigprocmask.c:130:1: error: expected ')' before '&=' token
sigdelset (sigset_t *set, int sig)
^
sigprocmask.c:151:22: error: expected ')' before '*' token
sigfillset (sigset_t *set)
^
sigprocmask.c:151:1: error: expected ')' before '=' token
sigfillset (sigset_t *set)
^
make[2]: *** [sigprocmask.o] Error 1
[... etc....]
I'm at a loss here. I tried omitting the "nostdlib" flag but then the configure step fails because the compiler can't find _exit (I'm building for a target without an OS so that makes sense). So then, what am I missing? Does libiconv depend on something that -nostdlib removes? If so then how does that explain the fact that these are apparently syntax errors?
So I guess my question boils down to: Is it even possible to build libiconv for a system without an OS? And if so, how do I overcome this current obstacle?