On Thursday 28 November 2002 08:00 pm, Dimitrie O. Paun wrote:
> On November 28, 2002 01:35 pm, Alexandre Julliard wrote:
> > > -CC=gcc
> > > +CC=wcc
> > >
> > > Q: Alexandre, would you accept such a utility in the tree?
> >
> > I don't know, I don't think you can write a one-size-fits-all script,
> > different apps will require different options, and then it will get
> > even more confusing IMO if you have two different ways of doing it
> > depending on your options. Maybe we should simply have a script
> > example in the documentation that people can adapt and ship with their
> > app if the makefile really makes it hard to set options.
>
> Sorry, maybe I was unclear. This wrapper will probably be a small C
> program that understands gcc's options. It needs to do the following:
> -- add the include dirs first
> -- add -fshort-wchar
> -- add -D__int8=char -D__int16=short -D__int32=int "-D__int64=long long"
> -- remove cygwin options not recognized by the Linux gcc
>
> If you think about them, it kindda makes sense, as under a Windowish
> environment these options are _implied_ in the invocation of gcc,
> just like -I /usr/include is implied when you invoke gcc under Linux.
>
> So to be honest, I don't see why it would be confusing, and second,
> why we can not have a one-size-fits-all wrapper.
>
> As I said, this is more a porting tool, to help you with the initial port.
> If the app has a configure script, you would want to instrument it to
> generate the correct flags for the compiler, and use gcc directly. But this
> is time consuming, and you have to worry about so many things at the
> beginning, I find it so much easier to have something working, and tweak
> only one thing at a time.
Some small ide from uClibc.
/*
* Copyright (C) 2000 Manuel Novoa III
*
* This is a crude wrapper to use uClibc with gcc.
* It was originally written to work around ./configure for ext2fs-utils.
* It certainly can be improved, but it works for me in the normal cases.
*
* April 7, 2001
*
* A bug was fixed in building the gcc command line when dynamic linking.
* The functions dlopen, etc. now work. At this time, you must make sure
* the correct libdl.so is included however. It is safest to, for example,
* add /lib/libdl.so.1 if using ld-linux.so.1 rather than adding -ldl to the
* command line.
*
* Note: This is only a problem if devel and target archs are the same. To
* avoid the problem, you can use a customized dynamic linker.
*
*
* April 18, 2001
*
* The wrapper now works with either installed and uninstalled uClibc versions.
* If you want to use the uninstalled header files and libs, either include
* the string "build" in the invocation name such as
* 'ln -s -uclibc-gcc -uclibc-gcc-build'
* or include it in the environment variable setting of UCLIBC_GCC.
* Note: This automatically enables the "rpath" behavior described below.
*
* The wrapper will now pass the location of the uClibc shared libs used to
* the linker with the "-rpath" option if the invocation name includes the
* string "rpath" or if the environment variable UCLIBC_GCC include it (as
* with "build" above). This is primarily intended to be used on devel
* platforms of the same arch as the target. A good place to use this feature
* would be in the uClibc/test directory.
*
* The wrapper now displays the command line passed to gcc when '-v' is used.
*
* May 31, 2001
*
* "rpath" and "build" behavior are now decoupled. You can of course get
* the old "build" behavior by setting UCLIBC_GCC="rpath-build". Order
* isn't important here, as only the substrings are searched for.
*
* Added environment variable check for UCLIBC_GCC_DLOPT to let user specify
* an alternative dynamic linker at runtime without using command line args.
* Since this wouldn't commonly be used, I made it easy on myself. You have
* to match the option you would have passed to the gcc wrapper. As an
* example,
*
* export UCLIBC_GCC_DLOPT="-Wl,--dynamic-linker,/lib/ld-alt-linker.so.3"
*
* This is really only useful if target arch == devel arch and DEVEL_PREFIX
* isn't empty. It involves a recompile, but you can at least test apps
* on your devel system if combined with the "rpath" behavor if by using
* LD_LIBRARY_PATH, etc.
*
* Also added check for "-Wl,--dynamic-linker" on the command line. The
* use default dynamic linker or the envirnment-specified dynamic linker
* is disabled in that case.
*
* Added options --uclibc-use-build-dir and --uclibc-use-rpath so that those
* behaviors can be invoked from the command line.
*
*/
/*
*
* TODO:
* Check/modify gcc-specific environment variables?
*/
#include
#include
#include
#include
#include "gcc-uClibc.h"
static char *rpath_link[] = {
"-Wl,-rpath-link,"UCLIBC_DEVEL_PREFIX"/lib",
"-Wl,-rpath-link,"UCLIBC_BUILD_DIR"/lib"
};
static char *rpath[] = {
"-Wl,-rpath,"UCLIBC_DEVEL_PREFIX"/lib",
"-Wl,-rpath,"UCLIBC_BUILD_DIR"/lib"
};
static char *uClibc_i