HomeFreeBSD

Add make rules to build LLVM IR from C/C++ sources.

Description

Add make rules to build LLVM IR from C/C++ sources.

As a foundation for future work with LLVM's Intermediate Representation (IR),
add new suffix rules that can be used to build .llo (text) or .bco (bitcode)
files from C or C++ sources. This compilation step uses the same CFLAGS, etc.,
as are used for building .o files, with the exception of optimization flags.
Many of the things we would like to do with IR (e.g., instrumentation) work
better with unoptimized code, so our approach is to build .c->.bco without
optimization and then apply the optimization in post-analysis,
post-instrumentation linking.

The overall result of these changes is:

  • one can "make foo.llo" or "make foo.bco" wherever "make foo.o" was supported
  • new make variables IR_CFLAGS and IR_CXXFLAGS are available to inspect the flags that are used by Clang to generate the IR

These new rules are added unconditionally to our non-POSIX suffix rule set,
since we cannot inspect COMPILER_TYPE in sys.mk. Future changes that depend
on these rules (e.g., building IR versions of binaries from bsd.prog.mk)
should use COMPILER_TYPE to determine when we can expect IR rules to succeed.

Reviewed by: emaste, imp
Approved by: rwatson (mentor)
Sponsored by: DARPA, AFRL
Differential Revision: https://reviews.freebsd.org/D4339

Details

Provenance
jonathanAuthored on
Reviewer
emaste
Differential Revision
D4339: Add suffix rules for LLVM IR and bitcode.
Parents
rS307675: Remove trailing whitespace from r307674
Branches
Unknown
Tags
Unknown