github.com/bytedance/sonic@v1.11.7-0.20240517092252-d2edb31b167b/scripts/build-arm.sh (about)

     1  #!/bin/bash
     2  
     3  # Define the directories
     4  SRC_DIR="native"
     5  TMP_DIR="output/arm"
     6  OUT_DIR="internal/native/neon"
     7  TOOL_DIR="tools"
     8  CC=clang
     9  if [ "$1" != "" ]; then
    10      CC=$1
    11  fi
    12  echo $CC
    13  
    14  # Create the output directory if it doesn't exist
    15  mkdir -p "$TMP_DIR"
    16  mkdir -p "$OUT_DIR"
    17  
    18  # Loop through all .c files in the source directory
    19  for src_file in "$SRC_DIR"/*.c; do
    20      # Extract the filename without the extension
    21      base_name=$(basename "$src_file" .c)
    22      
    23      # Define the output file path
    24      asm_file="$TMP_DIR/${base_name}.s"
    25  
    26      # Compile the source file into an assembly file
    27      $CC -Wno-error -Wno-nullability-completeness -mllvm=--go-frame -mllvm=--enable-shrink-wrap=0 -target aarch64-apple-macos11 -march=armv8-a+simd -Itools/simde/simde -mno-red-zone -fno-asynchronous-unwind-tables -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector -nostdlib -O3 -mno-red-zone -fno-asynchronous-unwind-tables -fno-builtin -fno-exceptions -fno-rtti -fno-stack-protector -nostdlib -S -o "$asm_file" "$src_file" 
    28  
    29      # Execute asm2asm tool
    30      python3 ${TOOL_DIR}/asm2arm/arm.py ${OUT_DIR}/${base_name}_arm64.go $asm_file
    31  
    32  done