aws-lc-fips-sys 0.14.2

AWS-LC is a general-purpose cryptographic library maintained by the AWS Cryptography team for AWS and their customers. This is the FIPS validated version of AWS-LC.
Documentation
#!/bin/sh
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: Apache-2.0 OR ISC

# Dynamically generated compiler wrapper script
# This file is generated by CMake from compiler_wrapper_template.sh.in
#
# Real compiler: @REAL_COMPILER@
# Generated on: @CURRENT_TIMESTAMP@
#
# Purpose: Filter out conflicting -c flags when -S flag is present.
# CMake always emits -c for static library targets, but the bcm_c_generated_asm
# target uses -S to produce textual assembly. The two flags are contradictory;
# this wrapper ensures -S wins regardless of compiler.

set -e

# The real compiler path (filled in by CMake)
REAL_COMPILER="@REAL_COMPILER@"

# Verify the compiler exists
if [ ! -x "$REAL_COMPILER" ]; then
    echo "Error: Compiler not found or not executable: $REAL_COMPILER" >&2
    exit 1
fi

# When used as COMPILER_LAUNCHER, the real compiler path is passed as first argument
# Skip it if it matches our configured REAL_COMPILER
if [ $# -gt 0 ] && [ "$1" = "$REAL_COMPILER" ]; then
    shift
fi

# Check if we have both -S and -c flags
has_s_flag=false
has_c_flag=false
for arg in "$@"; do
    case "$arg" in
        -S) has_s_flag=true ;;
        -c) has_c_flag=true ;;
    esac
done

# If we have both flags, filter out -c and rebuild argument list
filtered=false
if [ "$has_s_flag" = true ] && [ "$has_c_flag" = true ]; then
    # Build new argument list by iterating through original args
    new_args=""
    arg_count=0

    for arg in "$@"; do
        case "$arg" in
            -c)
                # Skip -c flag
                filtered=true
                ;;
            *)
                # Keep this argument - use positional parameter trick
                arg_count=$((arg_count + 1))
                eval "arg_$arg_count=\"\$arg\""
                ;;
        esac
    done

    # Rebuild $@ with filtered arguments
    set --
    i=1
    while [ $i -le $arg_count ]; do
        eval "set -- \"\$@\" \"\$arg_$i\""
        i=$((i + 1))
    done
fi

# Debug output
if [ -n "$COMPILER_WRAPPER_DEBUG" ]; then
    echo "WRAPPER DEBUG: Real compiler: $REAL_COMPILER" >&2
    if [ "$filtered" = true ]; then
        echo "WRAPPER DEBUG: Filtered out conflicting -c flag (keeping -S)" >&2
    fi
    echo "WRAPPER DEBUG: Executing: $REAL_COMPILER $*" >&2
fi

# Execute the real compiler
exec "$REAL_COMPILER" "$@"