[llvm-commits] PATCH: Add LLVM_ENABLE_STAGING option to CMake and configure

Tom Stellard thomas.stellard at amd.com
Mon Jul 30 13:10:22 PDT 2012


On Mon, Jul 30, 2012 at 03:01:40PM -0400, Justin Holewinski wrote:
> The only thing I would add (other than the autotools version), is a
> more descriptive error message for when a staged back-end is added
> to LLVM_TARGETS_TO_BUILD without setting LLVM_ENABLE_STAGING.
> 

Here is version 2 of the cmake patch with a more descriptive error
message and also a new patch that adds the --enable-staging-targets option
to the configure script.

-Tom


> On 07/30/2012 02:10 PM, Tom Stellard wrote:
> >Hi,
> >
> >The attached patched adds the LLVM_ENABLE_STAGING flag to CMake.  This
> >flag is disabled by default and must be enabled to build staging
> >targets.  There are no staging targets at the moment, so the flag
> >doesn't actually do anything yet.
> >
> >The idea for this patch comes from the LLVM staging area discussion thread[1]
> >on LLVM dev.
> >
> >Please Review.
> >
> >Thanks,
> >Tom
> >
> >[1] http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-July/052146.html
> >
> >
> >_______________________________________________
> >llvm-commits mailing list
> >llvm-commits at cs.uiuc.edu
> >http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
> 
> -- 
> Thanks,
> 
> Justin Holewinski
> 

> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits

-------------- next part --------------
diff --git autoconf/configure.ac autoconf/configure.ac
index 7d36a06..7732f9e 100644
--- autoconf/configure.ac
+++ autoconf/configure.ac
@@ -649,6 +649,27 @@ AC_DEFINE_UNQUOTED([ENABLE_TIMESTAMPS],$ENABLE_TIMESTAMPS,
 
 dnl Allow specific targets to be specified for building (or not)
 TARGETS_TO_BUILD=""
+
+dnl
+dnl Helper function for adding staged targets to TARGETS_TO_BUILD
+dnl
+add_staging_target() {
+    if test "x$enable_staging" = xno; then
+        AC_MSG_ERROR([$1 is a staging target, which means it is experimental
+                  and does not meet LLVM standards for backends.  In order
+                  to build this target, you specify the
+                  --enable-staging-targets flag.])
+    else
+        TARGETS_TO_BUILD="$1 $TARGETS_TO_BUILD"
+    fi
+}
+
+AC_ARG_ENABLE([staging-targets], AS_HELP_STRING([--enable-staging-targets],
+    [This option needs to be enable in order to specify staging targets with
+     the --enable-targets flag (default=disabled)]),
+     [enable_staging="$enableval"],
+     [enable_staging=no])
+
 AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
     [Build specific host targets: all or target1,target2,... Valid targets are:
      host, x86, x86_64, sparc, powerpc, arm, mips, spu, hexagon,
diff --git configure configure
index fcd9179..74c1964 100755
--- configure
+++ configure
@@ -1414,6 +1414,10 @@ Optional Features:
                           Win32 DLL (default is NO)
   --enable-timestamps     Enable embedding timestamp information in build
                           (default is YES)
+  --enable-staging-targets
+                          This option needs to be enable in order to specify
+                          staging targets with the --enable-targets flag
+                          (default=disabled)
   --enable-targets        Build specific host targets: all or
                           target1,target2,... Valid targets are: host, x86,
                           x86_64, sparc, powerpc, arm, mips, spu, hexagon,
@@ -5318,6 +5322,31 @@ _ACEOF
 
 
 TARGETS_TO_BUILD=""
+
+add_staging_target() {
+    if test "x$enable_staging" = xno; then
+        { { echo "$as_me:$LINENO: error: $1 is a staging target, which means it is experimental
+                  and does not meet LLVM standards for backends.  In order
+                  to build this target, you specify the
+                  --enable-staging-targets flag." >&5
+echo "$as_me: error: $1 is a staging target, which means it is experimental
+                  and does not meet LLVM standards for backends.  In order
+                  to build this target, you specify the
+                  --enable-staging-targets flag." >&2;}
+   { (exit 1); exit 1; }; }
+    else
+        TARGETS_TO_BUILD="$1 $TARGETS_TO_BUILD"
+    fi
+}
+
+# Check whether --enable-staging-targets was given.
+if test "${enable_staging_targets+set}" = set; then
+  enableval=$enable_staging_targets; enable_staging="$enableval"
+else
+  enable_staging=no
+fi
+
+
 # Check whether --enable-targets was given.
 if test "${enable_targets+set}" = set; then
   enableval=$enable_targets;
@@ -10210,7 +10239,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10213 "configure"
+#line 10242 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git projects/sample/autoconf/configure.ac projects/sample/autoconf/configure.ac
index bd0b16a..8d9f5d4 100644
--- projects/sample/autoconf/configure.ac
+++ projects/sample/autoconf/configure.ac
@@ -565,6 +565,33 @@ AC_DEFINE_UNQUOTED([ENABLE_TIMESTAMPS],$ENABLE_TIMESTAMPS,
 
 dnl Allow specific targets to be specified for building (or not)
 TARGETS_TO_BUILD=""
+
+dnl
+dnl Helper function for adding staged targets to TARGETS_TO_BUILD
+dnl
+add_staging_target() {
+    if test "x$enable_staging" = xno; then
+        AC_MSG_ERROR([$1 is a staging target, which means it is experimental
+                  and does not meet LLVM standards for backends.  In order
+                  to build this target, you specify the
+                  --enable-staging-targets flag.])
+    else
+        TARGETS_TO_BUILD="$1 $TARGETS_TO_BUILD"
+    fi
+}
+
+AC_ARG_ENABLE([staging-targets], AS_HELP_STRING([--enable-staging-targets],
+    [This option needs to be enable in order to specify staging targets with
+     the --enable-targets flag (default=disabled)]),
+     [enable_staging="$enableval"],
+     [enable_staging=no])
+
+AC_ARG_ENABLE([staging-targets], AS_HELP_STRING([--enable-staging-targets],
+    [This option needs to be enable in order to specify staging targets with
+     the --enable-targets flag (default=disabled)]),
+     [enable_staging="$enableval"],
+     [enable_staging=no])
+
 AC_ARG_ENABLE([targets],AS_HELP_STRING([--enable-targets],
     [Build specific host targets: all or target1,target2,... Valid targets are:
      host, x86, x86_64, sparc, powerpc, arm, mips, spu, hexagon,
diff --git projects/sample/configure projects/sample/configure
index df08c7c..25517f9 100755
--- projects/sample/configure
+++ projects/sample/configure
@@ -1399,6 +1399,10 @@ Optional Features:
                           Win32 DLL (default is YES)
   --enable-timestamps     Enable embedding timestamp information in build
                           (default is YES)
+  --enable-staging-targets
+                          This option needs to be enable in order to specify
+                          staging targets with the --enable-targets flag
+                          (default=disabled)
   --enable-targets        Build specific host targets: all or
                           target1,target2,... Valid targets are: host, x86,
                           x86_64, sparc, powerpc, arm, mips, spu, hexagon,
@@ -5244,6 +5248,39 @@ _ACEOF
 
 
 TARGETS_TO_BUILD=""
+
+add_staging_target() {
+    if test "x$enable_staging" = xno; then
+        { { echo "$as_me:$LINENO: error: $1 is a staging target, which means it is experimental
+                  and does not meet LLVM standards for backends.  In order
+                  to build this target, you specify the
+                  --enable-staging-targets flag." >&5
+echo "$as_me: error: $1 is a staging target, which means it is experimental
+                  and does not meet LLVM standards for backends.  In order
+                  to build this target, you specify the
+                  --enable-staging-targets flag." >&2;}
+   { (exit 1); exit 1; }; }
+    else
+        TARGETS_TO_BUILD="$1 $TARGETS_TO_BUILD"
+    fi
+}
+
+# Check whether --enable-staging-targets was given.
+if test "${enable_staging_targets+set}" = set; then
+  enableval=$enable_staging_targets; enable_staging="$enableval"
+else
+  enable_staging=no
+fi
+
+
+# Check whether --enable-staging-targets was given.
+if test "${enable_staging_targets+set}" = set; then
+  enableval=$enable_staging_targets; enable_staging="$enableval"
+else
+  enable_staging=no
+fi
+
+
 # Check whether --enable-targets was given.
 if test "${enable_targets+set}" = set; then
   enableval=$enable_targets;
@@ -10308,7 +10345,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 10311 "configure"
+#line 10348 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
-------------- next part --------------
diff --git CMakeLists.txt CMakeLists.txt
index bb64db9..788c929 100644
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -73,7 +73,7 @@ set(LLVM_TOOLS_BINARY_DIR ${LLVM_BINARY_DIR}/bin)
 set(LLVM_EXAMPLES_BINARY_DIR ${LLVM_BINARY_DIR}/examples)
 set(LLVM_LIBDIR_SUFFIX "" CACHE STRING "Define suffix of library directory name (32/64)" )
 
-set(LLVM_ALL_TARGETS
+set(LLVM_DEFAULT_TARGETS
   ARM
   CellSPU
   CppBackend
@@ -91,6 +91,14 @@ set(LLVM_ALL_TARGETS
 # List of targets with JIT support:
 set(LLVM_TARGETS_WITH_JIT X86 PowerPC ARM Mips)
 
+# List of staged targets.  These are not built by default.
+set (LLVM_STAGING_TARGETS )
+
+set (LLVM_ALL_TARGETS
+  ${LLVM_DEFAULT_TARGETS}
+  ${LLVM_STAGING_TARGETS}
+  )
+
 if( MSVC )
   set(LLVM_TARGETS_TO_BUILD X86
     CACHE STRING "Semicolon-separated list of targets to build, or \"all\".")
@@ -122,9 +130,11 @@ set(LLVM_TARGET_ARCH "host"
 option(LLVM_ENABLE_THREADS "Use threads if available." ON)
 
 if( LLVM_TARGETS_TO_BUILD STREQUAL "all" )
-  set( LLVM_TARGETS_TO_BUILD ${LLVM_ALL_TARGETS} )
+  set( LLVM_TARGETS_TO_BUILD ${LLVM_DEFAULT_TARGETS} )
 endif()
 
+option (LLVM_ENABLE_STAGING "Build staged backends" OFF)
+
 set(LLVM_ENUM_TARGETS "")
 foreach(c ${LLVM_TARGETS_TO_BUILD})
   list(FIND LLVM_ALL_TARGETS ${c} idx)
@@ -132,7 +142,17 @@ foreach(c ${LLVM_TARGETS_TO_BUILD})
     message(FATAL_ERROR "The target `${c}' does not exist.
     It should be one of\n${LLVM_ALL_TARGETS}")
   else()
-    set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${c})\n")
+    # Check if the target is a staged target
+    list (FIND LLVM_STAGING_TARGETS ${c} idx)
+    if ( idx GREATER -1 AND NOT LLVM_ENABLE_STAGING )
+      message(FATAL_ERROR "${c} is a staging target, which means it is experimental "
+                           "and does not meet LLVM standards for backends.  In order "
+                           "to build this target, you must turn on the "
+                           "LLVM_ENABLE_STAGING option.  For example:\n "
+                           "cmake ${CMAKE_SOURCE_DIR} -DLLVM_TARGETS_TO_BULD=\"${LLVM_TARGETS_TO_BUILD}\" -DLLVM_ENABLE_STAGING=1")
+    else()
+      set(LLVM_ENUM_TARGETS "${LLVM_ENUM_TARGETS}LLVM_TARGET(${c})\n")
+    endif()
   endif()
 endforeach(c)
 


More information about the llvm-commits mailing list