macososx-yosemitejam

jamplus: link command line too long for osx


I'm using jamplus to build a vendor's cross-platform project. On osx, the C tool's command line (fed via clang to ld) is too long.

Response files are the classic answer to command lines that are too long: jamplus states in the manual that one can generate them on the fly.

The example in the manual looks like this:

actions response C++
{
    $(C++) @@(-filelist @($(2)))
}

Almost there! If I specifically blow out the C.Link command, like this:

actions response C.Link
{
    "$(C.LINK)" $(LINKFLAGS) -o $(<[1]:C) -Wl,-filelist,@($(2:TC)) $(NEEDLIBS:TC) $(LINKLIBS:TC))
}

in my jamfile, I get the command line I need that passes through to the linker, but the response file isn't newline terminated, so link fails (osx ld requires newline-separated entries).

  1. Is there a way to expand a jamplus list joined with newlines? I've tried using the join expansion $(LIST:TCJ=\n) without luck. $(LIST:TCJ=@(\n)) doesn't work either. If I can do this, the generated file would hopefully be correct.
  2. If not, what jamplus code can I use to override the link command for clang, and generate the contents on the fly from a list? I'm looking for the least invasive way of handling this - ideally, modifying/overriding the tool directly, instead of adding new indirect targets wherever a link is required - since it's our vendor's codebase, as little edit as possible is desired.

Solution

  • The syntax you are looking for is:

    newLine = "
    " ;
    
    actions response C.Link
    {
        "$(C.LINK)" $(LINKFLAGS) -o $(<[1]:C) -Wl,-filelist,@($(2:TCJ=$(newLine))) $(NEEDLIBS:TC) $(LINKLIBS:TC))
    }
    

    To be clear (I'm not sure how StackOverflow will format the above), the newLine variable should be defined by typing:

    newLine = "" ;
    

    And then placing the carat between the two quotes and hitting enter. You can use this same technique for certain other characters, i.e.

    tab = "    " ;
    

    Again, start with newLine = "" and then place carat between the quotes and hit tab. In the above it is actually 4 spaces which is wrong, but hopefully you get the idea. Another useful one to have is:

    dollar = "$" ;
    

    The last one is useful as $ is used to specify variables typically, so having a dollar variable is useful when you actually want to specify a dollar literal. For what it is worth, the Jambase I am using (the one that ships with the JamPlus I am using), has this:

    SPACE = " " ;
    TAB = " " ;
    NEWLINE = "
    " ;
    

    Around line 28...