cross-compiling strace on non-Linux build

Alexey Neyman stilor at
Thu Jan 12 06:58:26 UTC 2017


I've encountered a problem with cross-compiling strace - as a part of 
crosstool-ng on MacOS [1]. While compiling ioctlsort.c, strace uses 
CC_FOR_BUILD, so it wants to include <linux/ioctl.h> header from the 
host - which is obviously missing on MacOS. Googling suggested replacing 
<linux/ioctl.h> with <sys/ioctl.h> - but I think this is wrong, as this 
will pick up build definitions and MacOS uses incompatible definitions 
for IOC_* macros (different bit shifts and different values for 

I worked this around by creating a temporary include directory and 
creating symlinks in that directory to {linux,asm,asm-generic} 
directories in *host* header directory [2], so that <linux/ioctl.h> is 
picked up from the host rather than from the build. This is a bit 
awkward, but it works.

A better solution would be to modify strace makefiles to get these 
headers from the host (e.g. by running CC-for-host with -E to generate a 
"header" with the appropriate IOC_* definitions; or by adding these 
definitions to the stuff gleaned by ioctl_*.sh from the Linux kernel 

Thoughts? Suggestions?

Best regards,


More information about the Strace-devel mailing list