Show linker command

Is it possible to see the actual linker command run when issuing (c|x)argo build? The --verbose flag only shows the RUSTFLAGS and the rustc invocation.

Please see my post “Some findings of the rust compilation process” just posted yesterday.

Ah, yes. That’s absolutely an approach. Seems a little tedious though. One could wish for a flag to just dump the commands to stderr.

The following is my link intercepter. It is for windows, and is ugly, as it uses mixed Windows and C-standard API.

#include <windows.h>
#include <tchar.h>
#include <string.h>
#include <io.h>
#include <fcntl.h>

TCHAR szLogFile[] = _T("linklog.txt");

void main()
{
    SYSTEMTIME st;
    TCHAR buff[32];
    LPTSTR cmdline;
    TCHAR *begin;
    int fd;

    GetSystemTime(&st);
    wsprintf(buff, _T("%04d.%02d.%02d:%02d:%02d:%02d:%03d: "), 
        st.wYear,
        st.wMonth,
        st.wDay,
        st.wHour,
        st.wMinute,
        st.wSecond,
        st.wMilliseconds);

    fd = _topen(szLogFile, _O_CREAT|_O_WRONLY|_O_APPEND|_O_TEXT);
    if (fd == -1)
        return;

    _write(fd, buff, 25*sizeof(TCHAR));

    cmdline = GetCommandLine();
    _write(fd, cmdline, _tcslen(cmdline)*sizeof(TCHAR));

    buff[0] = _T('\n');
    _write(fd, buff, sizeof(TCHAR));

    _close(fd);

    if (!(begin = _tcsstr(cmdline, _T("link"))))
        return;

    begin[1] = _T('j');
    _tsystem(cmdline);
}

On *nix things are much more simple.
You can run strace -f and see all commands that was executed by cargo , then trivial grep give you results.

Or if you want "intercepter" you can just write:

#!/bin/sh

echo "$@" >> /tmp/args.log
ld $@

I’m on Linux. strace was new to me, it solved the problem just fine. I just had to use the -s-flag set to a high number to get the arguments to arm-none-eabi-gcc untruncated. Thank you for the pointer. It’s fascinating how rich the *nix ecosystem is.

Now I just need to dive into the result and try to find out what goes wrong in the linking.