Index: clang/lib/Basic/Targets/AVR.cpp =================================================================== --- clang/lib/Basic/Targets/AVR.cpp +++ clang/lib/Basic/Targets/AVR.cpp @@ -377,7 +377,9 @@ MacroBuilder &Builder) const { Builder.defineMacro("AVR"); Builder.defineMacro("__AVR"); + Builder.defineMacro("__avr"); Builder.defineMacro("__AVR__"); + Builder.defineMacro("__avr__"); Builder.defineMacro("__ELF__"); if (!this->CPU.empty()) { Index: compiler-rt/cmake/Modules/CompilerRTUtils.cmake =================================================================== --- compiler-rt/cmake/Modules/CompilerRTUtils.cmake +++ compiler-rt/cmake/Modules/CompilerRTUtils.cmake @@ -168,6 +168,7 @@ check_symbol_exists(__wasm32__ "" __WEBASSEMBLY32) check_symbol_exists(__wasm64__ "" __WEBASSEMBLY64) check_symbol_exists(__ve__ "" __VE) + check_symbol_exists(__avr__ "" __AVR) if(__ARM) add_default_target_arch(arm) elseif(__AARCH64) @@ -212,6 +213,8 @@ add_default_target_arch(wasm64) elseif(__VE) add_default_target_arch(ve) + elseif(__AVR) + add_default_target_arch(avr) endif() endmacro() Index: compiler-rt/cmake/base-config-ix.cmake =================================================================== --- compiler-rt/cmake/base-config-ix.cmake +++ compiler-rt/cmake/base-config-ix.cmake @@ -248,6 +248,8 @@ test_target_arch(wasm64 "" "--target=wasm64-unknown-unknown") elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "ve") test_target_arch(ve "__ve__" "--target=ve-unknown-none") + elseif("${COMPILER_RT_DEFAULT_TARGET_ARCH}" MATCHES "avr") + test_target_arch(avr "__avr__" "--target=avr") endif() set(COMPILER_RT_OS_SUFFIX "") endif() Index: compiler-rt/cmake/builtin-config-ix.cmake =================================================================== --- compiler-rt/cmake/builtin-config-ix.cmake +++ compiler-rt/cmake/builtin-config-ix.cmake @@ -52,6 +52,7 @@ set(WASM32 wasm32) set(WASM64 wasm64) set(VE ve) +set(AVR avr) if(APPLE) set(ARM64 arm64 arm64e) @@ -63,7 +64,7 @@ ${X86} ${X86_64} ${ARM32} ${ARM64} ${HEXAGON} ${MIPS32} ${MIPS64} ${PPC32} ${PPC64} ${RISCV32} ${RISCV64} ${SPARC} ${SPARCV9} - ${WASM32} ${WASM64} ${VE}) + ${WASM32} ${WASM64} ${VE} ${AVR}) include(CompilerRTUtils) include(CompilerRTDarwinUtils) Index: compiler-rt/cmake/config-ix.cmake =================================================================== --- compiler-rt/cmake/config-ix.cmake +++ compiler-rt/cmake/config-ix.cmake @@ -203,8 +203,10 @@ # Detect whether the current target platform is 32-bit or 64-bit, and setup # the correct commandline flags needed to attempt to target 32-bit and 64-bit. +# AVR and MSP430 are omitted since they have 16-bit pointers. if (NOT CMAKE_SIZEOF_VOID_P EQUAL 4 AND - NOT CMAKE_SIZEOF_VOID_P EQUAL 8) + NOT CMAKE_SIZEOF_VOID_P EQUAL 8 AND + NOT ${arch} MATCHES "avr|msp430") message(FATAL_ERROR "Please use architecture with 4 or 8 byte pointers.") endif() Index: compiler-rt/lib/builtins/CMakeLists.txt =================================================================== --- compiler-rt/lib/builtins/CMakeLists.txt +++ compiler-rt/lib/builtins/CMakeLists.txt @@ -668,6 +668,11 @@ ${GENERIC_TF_SOURCES} ${GENERIC_SOURCES}) +set(avr_SOURCES + ${GENERIC_TF_SOURCES} + ${GENERIC_SOURCES} +) + add_custom_target(builtins) set_target_properties(builtins PROPERTIES FOLDER "Compiler-RT Misc")