From 1e5ecac0554aa3564bc27c25424cc52a357df8f0 Mon Sep 17 00:00:00 2001 From: Dakkshesh Date: Tue, 11 Feb 2025 00:38:17 +0530 Subject: [PATCH] configure: Add support for llvm-tools and add option to explicitly use them Signed-off-by: Dakkshesh --- configure.ac | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 748210677..fdbd361f5 100644 --- a/configure.ac +++ b/configure.ac @@ -133,6 +133,20 @@ m4_if(m4_defn([m4_PACKAGE_VERSION]), [2.64], [m4_foreach([_GCC_LANG], [C, C++, Fortran, Fortran 77], [m4_define([_AC_LANG_IO_PROGRAM(]_GCC_LANG[)], m4_defn([AC_LANG_PROGRAM(]_GCC_LANG[)]))])]) +# Add option to use LLVM tools +AC_ARG_ENABLE([use-llvm], + [AS_HELP_STRING([--enable-use-llvm], + [Use LLVM tools for AS, AR, RANLIB, OBJDUMP, LD])], + [use_llvm=$enableval], + [use_llvm=no]) + +if test "x$use_llvm" = "xyes"; then + : ${AR:=llvm-ar} + : ${AS:="llvm-mc"} + : ${LD:=lld} + : ${OBJDUMP:=llvm-objdump} + : ${RANLIB:=llvm-ranlib} +fi # Checks for programs. @@ -156,23 +170,28 @@ case "${CC}" in *) AC_MSG_ERROR(Wrong C compiler found; check the PATH!) ;; esac case "${AS}" in - *avr*as*) ;; + *llvm-mc*) + # We need to pass correct target flag for llvm-mc + AS_FLAGS="-arch=avr" + ;; + *avr*as*|*as*) + ;; *) AC_MSG_ERROR(Wrong assembler found; check the PATH!) ;; esac case "${LD}" in - *avr*ld*) ;; + *avr*ld*|*lld*) ;; *) AC_MSG_ERROR(Wrong linker found; check the PATH!) ;; esac case "${OBJDUMP}" in - *avr*objdump*) ;; + *avr*objdump*|*llvm*objdump*) ;; *) AC_MSG_ERROR(Wrong objdump found; check the PATH!) ;; esac case "${AR}" in - *avr*ar*) ;; + *avr*ar*|*llvm*ar*) ;; *) AC_MSG_ERROR(Wrong archiver found; check the PATH!) ;; esac case "${RANLIB}" in - *avr*ranlib*) ;; + *avr*ranlib*|*llvm*ranlib) ;; *) AC_MSG_ERROR(Wrong ranlib found; check the PATH!) ;; esac