This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: CDL and makefile output


Jesper Skov wrote:
> On Wed, Nov 12, 2008 at 10:15 PM, Bart Veer <bartv@ecoscentric.com> wrote:
>> If you really need to do something like this, it is possible but not
>> easy. You can invoke a Tcl script from inside a custom build step,
>> along similar lines to the memalloc package. That Tcl script can read
>> in install/include/pkgconf/ecos.mak and anything else in pkgconf/ that
>> contains relevant options, e.g. your CYGBLD_GLOBAL_EXTRAS_LDFLAGS. It
>> can then exec the linker with the appropriate options.
> 
> Uh, not liking the looks of that. Partly because I've never really
> used Tcl, partly because keeping the logic in the makefile would be
> nicer (IMHO, of course).
> 
> So I tried to see if I could do it in a simpler fashion. And I found a
> solution after some tinkering. The real question is now, would
> something like the below be accepted in a contribution?
> 
> Index: hal.cdl
> ===================================================================
> --- hal.cdl	(revision 26)
> +++ hal.cdl	(working copy)
> @@ -71,10 +71,22 @@
> 
>      make -priority 250 {
>          <PREFIX>/lib/extras.o: <PREFIX>/lib/libextras.a
> -        $(CC) $(CFLAGS) -nostdlib -Wl,-r -Wl,--whole-archive -o $@ $<
> +        $(CC) $(CFLAGS) $(shell grep " EXTRAS_LDFLAGS "
> $(PREFIX)/include/pkgconf/system.h | cut -d' '  -f 3-) -o $@ $<
>      }
> 
> +    cdl_option CYGBLD_GLOBAL_EXTRAS_LDFLAGS {
> +        display "Extras.o linker flags"
> +        flavor  data
> +	    parent  CYGBLD_GLOBAL_OPTIONS
> +        no_define
> +        define -file=system.h EXTRAS_LDFLAGS
> +        default_value { "-nostdlib -Wl,-r -Wl,--whole-archive" }
> +        description   "
> +            This option controls the extras.o linker flags. Individual
> +            packages may define options which override these global flags."
> +    }
> 
> 
> I have only tested in on BSD/OS X (where it works as intended) but I
> can't see why it shouldn't work on Linux and Windows/CygWin.

You've blocked out how bizarre cygwin can be sometimes :-). I remember
having problems with doing things like that because of text-mode mount
points in cygwin. Depending on where something was run from and/or the
value of the CYGWIN environment variable, you could get embedded carriage
returns cropping up in the output from things like that. Pipes were usually
the biggest headache. I'm not saying it would definitely happen. I don't
think even at the time I fully got my head round when it would and wouldn't
happen.

I don't know whether this is even more gross or not, but what you could do
is have a lower priority make rule in your platform HAL. So it would run
the unmodified hal.cdl generic version above, and then run your one,
replacing the extras.o file.

Another possibility might be to change the linker script. This would need
checking but I think extras.o is only referenced from the linker script,
and I don't think is referenced anywhere else. So your platform HAL could
generate a different filename to extras.o and the synth hal linker script
could have:

#ifndef CYGBLD_HAL_EXTRAS_FILENAME
#define CYGBLD_HAL_EXTRAS_FILENAME extras.o
#endif
INPUT(CYGBLD_HAL_EXTRAS_FILENAME)

What options do you need to add?

Jifl
-- 
eCosCentric Limited      http://www.eCosCentric.com/     The eCos experts
Barnwell House, Barnwell Drive, Cambridge, UK.       Tel: +44 1223 245571
Registered in England and Wales: Reg No 4422071.
------["Si fractum non sit, noli id reficere"]------       Opinions==mine

-- 
Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos
and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]