Create single .ptx (or .cubin) file from multiple .cu sources

Hey there!

Is it possible to create single ptx or cubin file from multiple cu sources?
Maybe compile sources to some intermediate representation (that comes before .ptx) and then link them into single ptx somehow?

I use CUDA Driver API (via JCuda) and my .cu files contain device code only.

Thanks!

I think it should be possible for cubin.

nvcc -cubin -dlink t1.cu t2.cu -o test.cubin

That works, thanks! But with very important remark: target architecture must be set with -arch nvcc flag.

So the final working solution is
nvcc -cubin -dlink -arch=sm_XY t1.cu t2.cu -o test.cubin,
where X is major and Y is minor version of device architecture. These parameters can be retrieved with cudaGetDeviceProperties (docs: https://www.cs.cmu.edu/afs/cs/academic/class/15668-s11/www/cuda-doc/html/group__CUDART__DEVICE_g5aa4f47938af8276f08074d09b7d520c.html)

More info about devices architectures flags http://docs.nvidia.com/cuda/cuda-compiler-driver-nvcc/#options-for-steering-gpu-code-generation