Cross Compiling LLVM's test-suite

Hi all,

I'm working in a company to port LLVM on their own processor.
I'm trying to run the test-suite, but it seems that it is usually run directly on the processor which is tested. In my case, I cannot run it on the processor, but I have a simulator on which I would like to run the test-suite.
Also, it seems to me that the test-suite start by compiling some tools that have to be run locally (so on x86), and then the test-suite compile all the tests, but with the same compiler as the one used to compile the tools.

My questions are :
   - Is it possible to compile the tools of the test-suite and all the tests with a different compiler?
   - Is it possible not to run the tests directly on the machine but on a simulator?

Best Regards,
Romaric

   - Is it possible to compile the tools of the test-suite and all the tests with a different compiler?

It is. Check CC / ORIGINAL_CC / TARGET_CC in the Makefiles.

   - Is it possible not to run the tests directly on the machine but on a simulator?

Yes, see RunSafely.sh. It has options for remote testing, or QEMU user
emulation.

I have not tried that myself, but I know it has been done in the past
and it should still be possible.

cheers,
--renato

Hi Romaric,

Yes, you can do this. I’m working on reworking the test-suite to make it substantially easier to do, but for the moment it does still work.

There is a “RUNUNDER” argument to the makefiles that you can use to prefix any command with your simulator. We find the easiest way to do it is to use binfmt_misc to ensure any ELF files compiled for your target get run via your simulator. Then the test-suite just works out of the box.

Hope this helps,

James

In lnt (http://llvm.org/docs/lnt/) you can run the test-suite with 'lnt runtest nt' and appropriate options. The --qemu-user-mode=qemu-command option will use the makefiles in the right way for qemu's linux user mode. --qemu-flag can be used to pass additional options. It should be fairly easy to adapt lnt's qemu support to other simulators if you need to.

I should mention that I typically point --qemu-user-mode at a wrapper script that sets some environment variables (QEMU_LD_PREFIX and LD_LIBRARY_PATH) before calling qemu itself. Otherwise my simulated program can't find the target libraries.