Issues with Unix Linking -- Want to modify build command for custom toolchain

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Issues with Unix Linking -- Want to modify build command for custom toolchain

Boost - Build mailing list
Hi all,

I've become quite frustrated over the past several days, not so much of an
issue with Boost but more of a "how do I do this" kind of problem. I've
gotten nowhere after many many hours digging through the boost.build source
files, so I come to you as my last resort.

I've got this fun embedded systems personal project where I am needing to
link together a whole bunch of static libraries. One of these libraries is
for FreeRTOS. FreeRTOS has this really awesome functionality where you can
implement callbacks for certain "oops" events, like stack overflows, malloc
ran out of memory, etc. I use these heavily in my projects as great way to
get notified when I screw up. Now here's the problem:

I use FreeRTOS on a wide variety of projects where the actual function hooks
are compiled into the top level lib/exe target. Basically I want different
behavior for these hooks depending on which project is running. Sounds good
right? Not quite so...the linker gets in this loop where my top target
depends on FreeRTOS, but FreeRTOS also depends on the top level target for
the hook declarations. Ultimately I am unable to link on a Unix system
(Ubuntu specifically) due to the ordering of the libraries. This is a well
known topic about boost.build I feel.

What I am trying (and miserably failing) to do is add the -Wl,--start-group
flag /before/ all the libraries I just compiled for my project are given to
the linker. For example, if I use the <link-flags> property, boost.build
will give me this kind of output:

<my-linker-executable> -o <output-location> <list-of-all-my-libs>
-Wl,--start-group <other-linked-libs> <rest-of-link-flags> ....and so on.

What I am trying to do is this:

<my-linker-executable> -o <output-location> -Wl,--start-group
<list-of-all-my-libs>  <other-linked-libs> <rest-of-link-flags> ....


I know this works because I've manually copied the failing link command,
edited it to include my start-group flag as described, and it all linked
successfully. Is there some kind of flag or modification I can do to get
this in the right location?! I'm using a custom toolchain
(gcc_arm_none_eabi) and the requisite .jam file to initialize it, which is
literally just a copy-paste of gcc.jam with the "gcc" replaced with
"gcc_arm_none_eabi". I have tried to modify the "rule link bind LIBRARIES
{}" command, but that had no effect, despite it looking very similar to the
actual link command shown in the failure message.

Thanks,
Brandon




--
Sent from: http://boost.2283326.n4.nabble.com/Boost-Build-f2685023.html
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Issues with Unix Linking -- Want to modify build command for custom toolchain

Boost - Build mailing list
First, thank you for using B2 :-) Second, we're going to need a bit more info to help you out. Can you tell us what version of B2 you are using? Do you have a minimal sample project that replicates the issue? What's in your config files? Can you provide that custom toolset? etc.

On Tue, Jun 4, 2019 at 6:31 AM codex653 via Boost-build <[hidden email]> wrote:
What I am trying (and miserably failing) to do is add the -Wl,--start-group
flag /before/ all the libraries I just compiled for my project are given to
the linker. For example, if I use the <link-flags> property, boost.build
will give me this kind of output:

<my-linker-executable> -o <output-location> <list-of-all-my-libs>
-Wl,--start-group <other-linked-libs> <rest-of-link-flags> ....and so on.

That is rather strange. Since from what I can tell B2 should already be putting the `-Wl,--start-group` at the front of all libraries (both built and externally searched) <https://github.com/boostorg/build/blob/develop/src/tools/gcc.jam#L1094

What I am trying to do is this:

<my-linker-executable> -o <output-location> -Wl,--start-group
<list-of-all-my-libs>  <other-linked-libs> <rest-of-link-flags> ....

Indeed. 


--
-- Rene Rivera
-- Grafik - Don't Assume Anything
-- Robot Dreams - http://robot-dreams.net


_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build
Reply | Threaded
Open this post in threaded view
|

Re: Issues with Unix Linking -- Want to modify build command for custom toolchain

Boost - Build mailing list
Certainly! According to b2 -v, I'm on 2018.02, OS=LINUX. But my full boost
"package" version I'm compiling with is boost_1_70_0.

Ah yeah a minimal example will be difficult right off the bat. All my
targets currently are for STM32 chips and only support the embedded
environment, aka you would have to install the gcc_arm_none_eabi toolchain,
clone my repo, etc...If necessary I can come up with a variant that will do
this same behavior, but with the run of the mill gcc. I have plans to do
this anyways, so I wouldn't feel bad if you wanted it.

In lieu of that however, the latest variant of my project that I've been
working on can be found here on the master branch:
https://github.com/brandonbraun653/Valkyrie
Try not to laugh too much at the jamfiles! I'm still learning!

I tried to build two variants of my executable target "valkyrie_stm32f4"
(Valkyrie/build.jam), one with the -Wl,--start-group flag and the other
without, and dumped the output at the -d2 level into
Valkyrie/normal_failing_link.txt and Valkyrie/start_group_failing_link.txt.

My gcc_arm_none_eabi.jam file can be found at:
Valkyrie/lib/CommonTools/boost-build/toolsets
I copy this into the actual boost-build toolchain src/tools directory on my
PC so that boost knows how to initialize it. That might not be the "best"
way of doing it, but it's working for now haha.


AHA! So I /did/ find the correct line that does the actual linking
command!!! I've been modifying the heck out of that in my
gcc_arm_none_eabi.jam file, even putting really stupid stuff that should
immediately break the linker, but yet somehow boost completely ignored every
change I made.



--
Sent from: http://boost.2283326.n4.nabble.com/Boost-Build-f2685023.html
_______________________________________________
Unsubscribe & other changes: https://lists.boost.org/mailman/listinfo.cgi/boost-build