craftr.ext.compiler.llvm

craftr.ext.compiler.llvm.detect(program)[source]

Assuming program points to Clang or Clang++, this function determines meta information about it. The returned dictionary contains the following keys:

Parameters:
  • version
  • version_str
  • name
  • target
  • thread_model
  • cpp_stdlib – (only present for C++ compilers)
Raises:
  • OSError – If program can not be executed (eg. if it does not exist).
  • ToolDetectionError – If program is not Clang or Clang++.
class craftr.ext.compiler.llvm.LlvmCompiler(program, language, desc=None, **kwargs)[source]

Interface for the LLVM compiler.

compile(sources, frameworks=(), target_name=None, **kwargs)[source]
Parameters:
  • sources – A list of input source files.
  • frameworks – List of Framework objects.
  • target_name – Override target name.

Supported framework options:

Parameters:
  • include – Additional include directories.
  • defines – Preprocessor definitions.
  • forced_include – Force includes for every compilation unit.
  • exceptions – Allows you to disable exceptions.
  • language – Override compilation language. Choices are 'c', 'cpp', 'asm'
  • debug – True ot disable optimizations and enable debugging symbols.
  • std – Set the C/C++ standard (--std argument)
  • pedantic – Enable the --pedantic flag
  • pic – Enable position independent code.
  • warn – Warning level. Choices are 'all', 'none' and None (latter is different in that it adds no warning related compiler flag at all).
  • optimize – Optimization level. Choices are 'debug', 'speed', 'size', 'none' and None
  • autodeps – True if automatic dependencies should be enabled (for recompiles when only headers change). Default is True.
  • description – Target description (shown during Ninja build).
  • osx_fwpath – Additional search path for OSX frameworks.
  • osx_frameworks – OSX frameworks to take into account.
  • program – Override the compiler command.
  • additional_flags – Additional flags for the compiler command-
  • gcc_additional_flags – Additional flags (GCC only).
  • gcc_compile_additional_flags – Additional flags (GCC only).
  • gcc_remove_flags – Flags to remove (GCC only).
  • gcc_compile_remove_flags – Flags to remove (GCC only).
  • llvm_additional_flags – Additional flags (LLVM only).
  • llvm_compile_additional_flags – Additional flags (LLVM only).
  • llvm_remove_flags – Flags to remove (LLVM only).
  • llvm_compile_remove_flags – Flags to remove (LLVM only).
Parameters:
  • output – The name of the output file. The platform-dependent appropriate suffix is automatically appended unless keep_suffix is True.
  • inputs – A list of input files/targets.
  • frameworks – List of additional Framework objects. Note that the frameworks of Target objects listed in inputs are taken into account automatically.
  • target_name – Override target name.

Supported framework options:

Parameters:
  • output_type – The output type. Can be 'bin' or 'dll'
  • keep_suffix – Do not replace the suffix of the specified output files.
  • debug – True to enable debug symbols and disable optimization.
  • libs – Additional library names to link with.
  • gcc_libs – Additional library names to link with (GCC only).
  • llvm_libs – Additional library names to link with (LLVM only).
  • linker_args – Additional linker aguments.
  • gcc_linker_args – Additional linker aguments (GCC only).
  • llvm_linker_args – Additional linker aguments (LLVM only).
  • linker_script – Linker script input file.
  • libpath – Additional search directory to search for libraries.
  • external_libs – Absolute paths of additional libraries to link with.
  • osx_fwpath – Additional search path for frameworks (OSX only).
  • osx_frameworks – Frameworks to link with (OSX only).
  • description – Target description (displayed during Ninja build).
  • program – Override the linker program to incoke.
  • additional_flags – Additional flags for the linker.
  • gcc_additional_flags – Additional flags for the linker (GCC only).
  • gcc_link_additional_flags – Additional flags for the linker (GCC only).
  • gcc_remove_flags – Flags to remove (GCC only).
  • gcc_link_remove_flags – Flags to remove (GCC only).
  • llvm_additional_flags – Additional flags for the linker (LLVM only).
  • llvm_link_additional_flags – Additional flags for the linker (LLVM only).
  • llvm_remove_flags – Flags to remove (LLVM only).
  • llvm_link_remove_flags – Flags to remove (LLVM only).

Target.meta variables:

Parameters:
  • link_output – The output filename of the link operation.
  • link_target – The filename of the target that can be passed into the linker. This is required because on Windows this needs to be a different value than link_output. Only valid with output_type='dll'.
name = 'LLVM'