Compiler Wrapper for Custom Code Transformations

Resolve Bottlenecks,
Find Innovative Solutions
Generate Solutions

Solution Overview

Problem

The changing behavior of compilers from version to version poses difficulties for software owners who need to recompile software to utilize new features, often requiring significant modifications to the source code or backporting features to older compiler versions, and also complicates the creation of hot patches for systems like operating systems or hypervisors without disrupting their operation.

Innovation Solution

A compiler system that introduces a custom code transformation stage during the compilation process, allowing the injection of custom code transformations into the assembly or intermediate code, enabling the implementation of new features in older compiler versions without modifying the compiler itself, using a wrapper program to intercept compiler invocations and perform custom transformations such as security updates and instrumentation.

Engineering Contradictions & Design Principles

VSEngineering Contradiction Analysis

1Adaptability or versatility

If a new version of the compiler is used to recompile software to utilize new features, then the software can access new compiler features and improvements, but significant modifications to the source code are required or the compilation may fail entirely

Engineering Contradiction:
Improveaccess to new compiler featuresVSAvoidsource code modification effort
Core Design Contradiction:
Adaptability or versatilityVSEase of manufacture

Solution Approach 1:

The patent introduces an intermediary component - a custom code transformation stage - that acts as a mediator between the source code and the compilation process. This transformation stage intercepts the compilation workflow, applies custom transformations to the source code or intermediate representation, and then passes the transformed code to the compiler. This allows new compiler features to be utilized without requiring modifications to the original source code, as the transformation stage handles the necessary adaptations.

Inventive Principle:
Principle #24Intermediary (Mediator)

Solution Approach 2:

The compilation process is segmented into distinct stages: the original compilation process, a custom code transformation stage, and the final compilation stage. By dividing the compilation workflow and inserting the transformation stage in between, the system can apply feature-specific transformations without affecting the original source code or requiring changes to the compiler itself. This segmentation enables incremental adoption of new features.

Inventive Principle:
Principle #1Segmentation

2Reliability

If the same version of the compiler is used to create hot patches, then compatibility with the existing system is maintained, but desired compiler features that are not available in the original version cannot be implemented

Engineering Contradiction:
Improvehot patch compatibilityVSAvoidavailability of compiler features
Core Design Contradiction:
ReliabilityVSAdaptability or versatility

Solution Approach 1:

The custom code transformation stage performs preliminary actions on the source code or intermediate representation before compilation. By applying transformations in advance - such as inserting instrumentation code, modifying control flow, or adding security checks - the system can incorporate features from newer compiler versions into hot patches while maintaining compatibility with the original compiler version used by the target system. The transformations prepare the code in a way that enables new features without requiring the actual compiler version to be upgraded.

Inventive Principle:
Principle #10Preliminary action

3Adaptability or versatility

If significant modifications are made to the source code to backport features to an old compiler version, then the desired compiler features become available, but the process is extremely difficult and time-consuming

Engineering Contradiction:
Improvefeature availability in old compilerVSAvoidbackporting time
Core Design Contradiction:
Adaptability or versatilityVSLoss of time

Solution Approach 1:

Instead of modifying the original source code to backport features, the system creates a copy or representation of the source code at the intermediate representation level and applies transformations to this copy. The custom code transformation stage works with the intermediate representation, which is a simplified and standardized form of the code, making transformations easier and faster to apply. This avoids the complexity of directly modifying source code while achieving the same effect of enabling new features in old compiler versions.

Inventive Principle:
Principle #26Copying

Data Source

PatentUS10698668B1Custom code transformations during compilation process
Publication Date: 2020.06.30 AMAZON TECH INC
  • US10698668B1 patent drawing
  • US10698668B1 patent drawing
  • US10698668B1 patent drawing

AI summary

Computer systems and associated methods are disclosed for performing custom code transformations using a compiler that does not support the custom transformations. In embodiments, a wrapper program intercepts a command to the compiler. The wrapper program generates intermediate code using the compiler in accordance with the command. The wrapper program then performs the code transformations on the intermediate code using a code transformer, for example, by performing a search and replace operation to replace particular code sequences in the intermediate code. The wrapper program then generates the binary code from the transformed intermediate code in accordance with the command. In this manner, software may be compiled with the custom code transformations without extensive changes to the source code or the compiler. In one application, the technique may be used to build a hot patch that applies a security update to a software using the software's original compiler.