Compiler Configuration Emulation for Static Analysis

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

Existing compiler emulations struggle to accurately mimic the behavior of different compilers due to varying configuration properties and implementation-specific constructs, leading to inconsistencies in source code compilation across different compilers.

Innovation Solution

A system that automatically determines the configuration properties of compilers used in a build system and configures a compiler emulator to precisely emulate the behavior of these compilers, distinguishing between actual compilers and non-compiler executables.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Reliability

If a compiler emulator is used to mimic compiler behavior, then static analysis can be performed without executing source code, but the emulator fails to accurately replicate compiler behavior due to varying configuration properties and implementation-specific constructs

Engineering Contradiction:
Improveaccuracy of compiler behavior emulationVSAvoidcomplexity of configuring emulator with compiler-specific properties
Core Design Contradiction:
ReliabilityVSDevice complexity

Solution Approach 1:

The system performs preliminary actions by automatically detecting the build system's compiler configuration properties before static analysis begins. The property detection mechanism examines the build system environment, identifies compiler-specific properties (such as preprocessor macros, optimization levels, and standard library versions), and configures the emulator with these properties in advance. This preliminary configuration ensures the emulator accurately replicates compiler behavior throughout the static analysis process.

Inventive Principle:
Principle #10Preliminary action

Solution Approach 2:

The system enables self-service by allowing the build system to automatically provide its own configuration properties to the emulator. Through hooks and integration points, the build system exposes its compiler invocation parameters, environment variables, and configuration files directly to the property detection mechanism. This self-service approach eliminates manual configuration efforts and ensures the emulator receives authentic compiler properties from the actual build environment.

Inventive Principle:
Principle #25Self-service

2Measurement precision

If the emulator is configured with multiple compiler-specific properties to improve accuracy, then behavior mimicry improves, but the configuration process becomes more complex and difficult to maintain

Engineering Contradiction:
Improveprecision of compiler behavior replicationVSAvoidease of configuring and maintaining emulator
Core Design Contradiction:
Measurement precisionVSEase of operation

Solution Approach 1:

The build system automatically provides its own configuration properties through integrated hooks and event listeners. When the build system invokes compilers, it exposes parameters such as optimization flags, preprocessor definitions, and target architectures directly to the property detection mechanism. This self-service model eliminates manual configuration and ensures the emulator receives authentic, up-to-date compiler properties without requiring user intervention.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The system implements feedback loops where the property detection mechanism continuously monitors build system behavior and adjusts emulator configuration accordingly. When the build system changes compiler properties or adds new configuration options, the detection mechanism captures these changes and updates the emulator configuration in real-time. This feedback ensures the emulator maintains precise behavior replication even as the build system evolves.

Inventive Principle:
Principle #23Feedback

3Reliability

If manual configuration of compiler properties is performed, then some accuracy can be achieved, but it requires significant user effort and expertise to identify and set all relevant properties

Engineering Contradiction:
Improveaccuracy of emulationVSAvoidautomation of compiler property detection
Core Design Contradiction:
ReliabilityVSExtent of automation

Solution Approach 1:

The build system automatically exposes its compiler configuration properties through integrated hooks, eliminating the need for manual identification and configuration. The property detection mechanism automatically queries the build system environment, captures compiler invocation parameters, and configures the emulator without user intervention. This automation transforms a previously manual, expertise-intensive process into an autonomous system that works seamlessly with the build system.

Inventive Principle:
Principle #25Self-service

Solution Approach 2:

The property detection mechanism serves as an intermediary between the build system and the compiler emulator. It automatically captures compiler properties from the build system through hooks and event listeners, processes this information, and translates it into appropriate emulator configuration parameters. This intermediary layer automates the complex task of property mapping and configuration, requiring no user expertise while ensuring accurate emulation.

Inventive Principle:
Principle #24Intermediary (Mediator)

4Measurement precision

If the build system is modified to support emulator integration, then more accurate property detection is possible, but modifying the build system introduces complexity and potential disruptions

Engineering Contradiction:
Improveprecision of property detectionVSAvoidcomplexity of integrating with build system
Core Design Contradiction:
Measurement precisionVSDevice complexity

Solution Approach 1:

The property detection mechanism acts as an intermediary that interfaces with the build system through standardized hooks and event listeners rather than requiring deep integration or modification of build system core functionality. It captures compiler properties through these standardized interfaces and processes them independently, minimizing the complexity of integration while maintaining high detection precision.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The detection mechanism is designed with universal interfaces that can work with multiple build systems through common hooks and event patterns. Rather than requiring custom integration for each build system, it uses multi-functional interfaces that accommodate different build environments, reducing integration complexity while maintaining precise property detection across diverse build systems.

Inventive Principle:
Principle #6Universality (Multi-functionality)

Data Source

PatentEP3147783B1Automatic determination of compiler configuration
Publication Date: 2020.11.18 MICROSOFT TECHNOLOGY LICENSING LLC
  • EP3147783B1 patent drawingFigure 1
  • EP3147783B1 patent drawingFigure 2
  • EP3147783B1 patent drawingFigure 3

AI summary

Methods, systems, and apparatus, including computer programs encoded on computer storage media, for automatically determining configuration properties of a compiler. One of the methods includes determining that an executable of the newly created process is a compiler called by the build system to compile source code of a source code file. In response to the determining, a plurality of configuration properties of the compiler called by the build system are determined, the configuration properties including first properties of a plurality of built-in functions of the compiler, second properties of a plurality of built-in types of the compiler, or both. A compiler emulator is configured to emulate the behavior of the compiler called by the build system using the determined configuration properties. Access to the source code is provided to the compiler emulator configured using the determined configuration properties.