boost-build (aka bjam) with Intel archiver command instead of ar

452 views Asked by At

When I use boost-build with the Intel compiler, using the built-in "intel" tool, it uses icpc when compiling source into object files, but uses ar to make .a static libraries. Normally this is perfectly fine because Intel's own archiver xiar is mostly a wrapper for ar.

However, I'm trying to use Intel's "inter-procedural optimization" (-ipo) option when I build some (but not all) of my libraries/modules within a large application. I want it to optimize within the library/module, but not between libraries/modules. For that to work, I have to use xiar or xild -lib when making the .a files because ar doesn't understand the .o files that are created by icpc -ipo. It thinks it succeeds, but the .a it makes will fail in the linking stage.

How can I change what command boost-build will use to create archives away from the default ar to xiar?

I've tried throwing in <linker> (which I see the msvc built-in tool supports) to the using intel statement in my user-config.jam, but it seems to have been ignored. And I don't know that would affect the archiver choice anyway.

1

There are 1 answers

0
RaveTheTadpole On

I had to hack into boost-build's internals to make this work. If you need this feature, you can hack it too!

In /usr/share/boost-build/tools/intel-linux.jam or perhaps /usr/share/boost-build/src/tools/intel-linux.jam (which one exists might depend on you boost-build version), add the following to the end of the file:

actions piecemeal archive
{
    "xiar" $(AROPTIONS) rc "$(<)" "$(>)"
    "ranlib" "$(<)"
}

This seems to override the default archive (and piecemeal?) actions that are defined in gcc.jam. Here I explicitly use xiar instead of ar, and the rest is just copied verbatim.

If you aren't using Linux, you could probably move the same logic into intel-win.jam.

I believe that boost-build is flawed in this assumption to use ar even with the intel compiler, so this might become a bug fix request on boost-build soon. I'm not confident I have the best solution, but it's better than nothing.

Even better would be to add a <archiver> feature. Such a thing is mentioned in google results, but definitely doesn't exist in boost-build (between 2011 and 2014 versions). Obviously boost-build is capable of implementing such things. But I lack the skills in the very confusing jam language to make that happen. Please share if you do have such skills.