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

Tom Stellard thomas.stellard at amd.com
Tue Jul 31 07:45:27 PDT 2012


On Mon, Jul 30, 2012 at 06:32:53PM -0400, Justin Holewinski wrote:
> On Mon, Jul 30, 2012 at 4:10 PM, Tom Stellard <thomas.stellard at amd.com>wrote:
> 
> > 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.
> >
> 
> Looks good to me, with the caveat that my autoconf-fu is pretty weak.
> 
> 

Here are updated patches with s/STAGING/EXPERIMENTAL/.

-Tom


> >
> > -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
> >
> >
> 
> 
> -- 
> 
> Thanks,
> 
> Justin Holewinski
-------------- next part --------------
diff --git autoconf/configure.ac autoconf/configure.ac
index 7d36a06..fe1c8c9 100644
--- autoconf/configure.ac
+++ autoconf/configure.ac
@@ -649,6 +649,26 @@ 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 experimental targets to TARGETS_TO_BUILD
+dnl
+add_experimental_target() {
+    if test "x$enable_experimental" = xno; then
+        AC_MSG_ERROR([$1 is an experimental target and does not meet LLVM
+                  standards for backends.  In order to build this target,
+                  you specify the --enable-experimental-targets flag.])
+    else
+        TARGETS_TO_BUILD="$1 $TARGETS_TO_BUILD"
+    fi
+}
+
+AC_ARG_ENABLE([experimental-targets], AS_HELP_STRING([--enable-experimental-targets],
+    [This option needs to be enabled in order to specify experimental targets with
+     the --enable-targets flag (default=disabled)]),
+     [enable_experimental="$enableval"],
+     [enable_experimental=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..be179b8 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-experimental-targets
+                          This option needs to be enabled in order to specify
+                          experimental 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,29 @@ _ACEOF
 
 
 TARGETS_TO_BUILD=""
+
+add_experimental_target() {
+    if test "x$enable_experimental" = xno; then
+        { { echo "$as_me:$LINENO: error: $1 is an experimental target and does not meet LLVM
+                  standards for backends.  In order to build this target,
+                  you specify the --enable-experimental-targets flag." >&5
+echo "$as_me: error: $1 is an experimental target and does not meet LLVM
+                  standards for backends.  In order to build this target,
+                  you specify the --enable-experimental-targets flag." >&2;}
+   { (exit 1); exit 1; }; }
+    else
+        TARGETS_TO_BUILD="$1 $TARGETS_TO_BUILD"
+    fi
+}
+
+# Check whether --enable-experimental-targets was given.
+if test "${enable_experimental_targets+set}" = set; then
+  enableval=$enable_experimental_targets; enable_experimental="$enableval"
+else
+  enable_experimental=no
+fi
+
+
 # Check whether --enable-targets was given.
 if test "${enable_targets+set}" = set; then
   enableval=$enable_targets;
@@ -10210,7 +10237,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 10240 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
diff --git projects/sample/autoconf/configure.ac projects/sample/autoconf/configure.ac
index bd0b16a..1e352ea 100644
--- projects/sample/autoconf/configure.ac
+++ projects/sample/autoconf/configure.ac
@@ -565,6 +565,32 @@ 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 experimental targets to TARGETS_TO_BUILD
+dnl
+add_experimental_target() {
+    if test "x$enable_experimental" = xno; then
+        AC_MSG_ERROR([$1 is an experimental target and does not meet LLVM
+                  standards for backends.  In order to build this target,
+                  you specify the --enable-experimental-targets flag.])
+    else
+        TARGETS_TO_BUILD="$1 $TARGETS_TO_BUILD"
+    fi
+}
+
+AC_ARG_ENABLE([experimental-targets], AS_HELP_STRING([--enable-experimental-targets],
+    [This option needs to be enabled in order to specify experimental targets with
+     the --enable-targets flag (default=disabled)]),
+     [enable_experimental="$enableval"],
+     [enable_experimental=no])
+
+AC_ARG_ENABLE([experimental-targets], AS_HELP_STRING([--enable-experimental-targets],
+    [This option needs to be enable in order to specify experimental targets with
+     the --enable-targets flag (default=disabled)]),
+     [enable_experimental="$enableval"],
+     [enable_experimental=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..f593010 100755
--- projects/sample/configure
+++ projects/sample/configure
@@ -1399,6 +1399,14 @@ Optional Features:
                           Win32 DLL (default is YES)
   --enable-timestamps     Enable embedding timestamp information in build
                           (default is YES)
+  --enable-experimental-targets
+                          This option needs to be enabled in order to specify
+                          experimental targets with the --enable-targets flag
+                          (default=disabled)
+  --enable-experimental-targets
+                          This option needs to be enable in order to specify
+                          experimental 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 +5252,37 @@ _ACEOF
 
 
 TARGETS_TO_BUILD=""
+
+add_experimental_target() {
+    if test "x$enable_experimental" = xno; then
+        { { echo "$as_me:$LINENO: error: $1 is an experimental target and does not meet LLVM
+                  standards for backends.  In order to build this target,
+                  you specify the --enable-experimental-targets flag." >&5
+echo "$as_me: error: $1 is an experimental target and does not meet LLVM
+                  standards for backends.  In order to build this target,
+                  you specify the --enable-experimental-targets flag." >&2;}
+   { (exit 1); exit 1; }; }
+    else
+        TARGETS_TO_BUILD="$1 $TARGETS_TO_BUILD"
+    fi
+}
+
+# Check whether --enable-experimental-targets was given.
+if test "${enable_experimental_targets+set}" = set; then
+  enableval=$enable_experimental_targets; enable_experimental="$enableval"
+else
+  enable_experimental=no
+fi
+
+
+# Check whether --enable-experimental-targets was given.
+if test "${enable_experimental_targets+set}" = set; then
+  enableval=$enable_experimental_targets; enable_experimental="$enableval"
+else
+  enable_experimental=no
+fi
+
+
 # Check whether --enable-targets was given.
 if test "${enable_targets+set}" = set; then
   enableval=$enable_targets;
@@ -10308,7 +10347,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 10350 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
-------------- next part --------------
diff --git CMakeLists.txt CMakeLists.txt
index bb64db9..49c1fea 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 experimental targets.  These are not built by default.
+set (LLVM_EXPERIMENTAL_TARGETS )
+
+set (LLVM_ALL_TARGETS
+  ${LLVM_DEFAULT_TARGETS}
+  ${LLVM_EXPERIMENTAL_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_EXPERIMENTAL "Build experimental backends" OFF)
+
 set(LLVM_ENUM_TARGETS "")
 foreach(c ${LLVM_TARGETS_TO_BUILD})
   list(FIND LLVM_ALL_TARGETS ${c} idx)
@@ -132,7 +142,18 @@ 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 experimanetal
+    list (FIND LLVM_EXPERIMENTAL_TARGETS ${c} idx)
+    if ( idx GREATER -1 AND NOT LLVM_ENABLE_EXPERIMENTAL )
+      message(FATAL_ERROR "${c} is an experimental target "
+                           "and does not meet LLVM standards for backends.  In order "
+                           "to build this target, you must turn on the "
+                           "LLVM_ENABLE_EXPERIMENTAL option.  For example:\n "
+                           "cmake ${CMAKE_SOURCE_DIR} -DLLVM_TARGETS_TO_BULD=\""
+                           "${LLVM_TARGETS_TO_BUILD}\" -DLLVM_ENABLE_EXPERIMENTAL=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