MAC OS X Weirdness
-
Include the following at the top of your C file to get past CIL not properly handling some OS X extensions:
#ifdef __APPLE__ #include<Availability.h> #undef __OSX_AVAILABLE_STARTING #define __OSX_AVAILABLE_STARTING(_mac, _iphone) #undef __OSX_AVAILABLE_BUT_DEPRECATED #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) #undef __OSX_AVAILABLE_BUT_DEPRECATED_MSG #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) #undef __BLOCKS__ #endif
or, if you're running Sierra,#ifdef __APPLE__ #include<Availability.h> #include<sys/cdefs.h> #undef __OSX_AVAILABLE_STARTING #define __OSX_AVAILABLE_STARTING(_mac, _iphone) #undef __OSX_AVAILABLE_BUT_DEPRECATED #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) #undef __OSX_AVAILABLE_BUT_DEPRECATED_MSG #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) #undef __OSX_DEPRECATED #define __OSX_DEPRECATED(_start, _dep, _msg) #undef __IOS_DEPRECATED #define __IOS_DEPRECATED(_start, _dep, _msg) #undef __TVOS_DEPRECATED #define __TVOS_DEPRECATED(_start, _dep, _msg) #undef __WATCHOS_DEPRECATED #define __WATCHOS_DEPRECATED(_start, _dep, _msg) #undef __OSX_AVAILABLE #define __OSX_AVAILABLE(_arg) #undef __IOS_AVAILABLE #define __IOS_AVAILABLE(_arg) #undef __TVOS_AVAILABLE #define __TVOS_AVAILABLE(_arg) #undef __WATCHOS_AVAILABLE #define __WATCHOS_AVAILABLE(_arg) #undef __OSX_PROHIBITED #define __OSX_PROHIBITED #undef __IOS_PROHIBITED #define __IOS_PROHIBITED #undef __TVOS_PROHIBITED #define __TVOS_PROHIBITED #undef __WATCHOS_PROHIBITED #define __WATCHOS_PROHIBITED #undef __OS_AVAILABILITY_MSG #define __OS_AVAILABILITY_MSG(a,b,c) #undef __BLOCKS__ #undef _Nullable #define _Nullable #undef _Nonnull #define _Nonnull #undef __swift_unavailable #define __swift_unavailable(_msg) #endif
or run Tigress withtigress -include $TIGRESS_HOME/apple.h --Transform=...
If you know how to automatically strip out all Apple-specific #defines, please let me know... -
Compile with
-fgnu89-inline
to get past a redeclaration bug in MAC OS 10.9. For an explanation, see, for example, http//sourceforge.net/p/resil/tickets/6.
-
Compile with
-Wno-builtin-requires-header
to avoid a spurious warning generated by clang.
Linux Weirdness
-
If you see something like this:
/usr/include/bits/mathcalls-helper-functions.h[21:12-28] : syntax error Parsing errorFatal error: exception Frontc.ParseError("Parse error")
you have run into an issue with recent versions of glibc which now support 128-bit floats (Tigress doesn't). There are two potentiall ways to fix this:
-
add
-D _Float128=double
to the Tigress command line -
add
#undef __HAVE_DISTINCT_FLOAT128
before including math.h
-
32-vs-64-bit machine models
By default, we assume you're generating code for the machine on which you execute Tigress on. If this is not the case, in particular, if your target machine has a different wordsize, you must
set this environment variable with the relevant C type sizes
CIL_MACHINE="short=2,2 int=4,4 long=4,4 long_long=8,8 pointer=4,4 \ alignof_enum=4 float=4,4 double=8,8 long_double=12,12 \ void=1 bool=1,1 fun=1,1 alignof_string=1 max_alignment=16 \ size_t=unsigned_int wchar_t=int char_signed=true const_string_literals=true \ big_endian=false __thread_is_keyword=true __builtin_va_list=true \ underscore_name=true";export CIL_MACHINE;
run Tigress with the --envmachine option.
For the current version of Tigress, this is really only relevant for the virtualize transformation. See the CIL documentation for more information.
Cross Compilation
From the CIL documentation:
- --gcc=command Tell cilly to use command to invoke gcc, e.g. --gcc=arm-elf-gcc to use a cross-compiler. See also the --envmachine option below that tells CIL to assume a different machine model.
CIL Weirdness
CIL (and hence Tigress), fails on the following:- Gcc torture test pr15296.c:
typedef int __attribute__ ((mode (__pointer__))) intptr_t;
- __alignof__(void).