[DynInst_API:] [PATCH] Enable ASM_NASM for i386 linux/freebsd


Date: Tue, 20 May 2014 14:41:12 -0700
From: Josh Stone <jistone@xxxxxxxxxx>
Subject: [DynInst_API:] [PATCH] Enable ASM_NASM for i386 linux/freebsd
The file test6LS-x86.asm can only be compiled with nasm, but cmake was
trying GNU as.  So enable ASM_NASM and set the PLATFORM define it wants.

CMake only gained NASM support in 2.8.4, so I've also copied those
supporting files.  (with the appropriate license declarations)
---
 CMakeLists.txt                                     |  3 +
 cmake/Modules/CMakeASM_NASMInformation.cmake       | 65 ++++++++++++++++++++++
 cmake/Modules/CMakeDetermineASM_NASMCompiler.cmake | 46 +++++++++++++++
 cmake/Modules/CMakeTestASM_NASMCompiler.cmake      | 42 ++++++++++++++
 i386-unknown-freebsd7.2/srclists.cmake             |  1 +
 i386-unknown-linux2.4/srclists.cmake               |  1 +
 src/specification/cmake_mutatees.py                |  6 ++
 7 files changed, 164 insertions(+)
 create mode 100644 cmake/Modules/CMakeASM_NASMInformation.cmake
 create mode 100644 cmake/Modules/CMakeDetermineASM_NASMCompiler.cmake
 create mode 100644 cmake/Modules/CMakeTestASM_NASMCompiler.cmake

diff --git a/CMakeLists.txt b/CMakeLists.txt
index a8850588dba5..de588495debb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,6 +52,9 @@ set (INSTALL_DIR "bin/testsuite" CACHE PATH "Testsuite installation directory")
 
 if (UNIX)
 enable_language(ASM-ATT)
+if ("${DYNINST_PLATFORM}" MATCHES "i386")
+enable_language(ASM_NASM)
+endif()
 elseif(WIN32)
 enable_language(ASM_MASM)
 add_definitions(-Dsnprintf=_snprintf)
diff --git a/cmake/Modules/CMakeASM_NASMInformation.cmake b/cmake/Modules/CMakeASM_NASMInformation.cmake
new file mode 100644
index 000000000000..062e8906bdb7
--- /dev/null
+++ b/cmake/Modules/CMakeASM_NASMInformation.cmake
@@ -0,0 +1,65 @@
+
+#=============================================================================
+# Copyright 2010 Kitware, Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+#   nor the names of their contributors may be used to endorse or promote
+#   products derived from this software without specific prior written
+#   permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+# support for the nasm assembler
+
+set(CMAKE_ASM_NASM_SOURCE_FILE_EXTENSIONS nasm asm)
+
+if(NOT CMAKE_ASM_NASM_OBJECT_FORMAT)
+  if(WIN32)
+    if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+      set(CMAKE_ASM_NASM_OBJECT_FORMAT win64)
+    else()
+      set(CMAKE_ASM_NASM_OBJECT_FORMAT win32)
+    endif()
+  elseif(APPLE)
+    if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+      set(CMAKE_ASM_NASM_OBJECT_FORMAT macho64)
+    else()
+      set(CMAKE_ASM_NASM_OBJECT_FORMAT macho)
+    endif()
+  else()
+    if(CMAKE_C_SIZEOF_DATA_PTR EQUAL 8)
+      set(CMAKE_ASM_NASM_OBJECT_FORMAT elf64)
+    else()
+      set(CMAKE_ASM_NASM_OBJECT_FORMAT elf)
+    endif()
+  endif()
+endif()
+
+set(CMAKE_ASM_NASM_COMPILE_OBJECT "<CMAKE_ASM_NASM_COMPILER> <FLAGS> -f ${CMAKE_ASM_NASM_OBJECT_FORMAT} -o <OBJECT> <SOURCE>")
+
+# Load the generic ASMInformation file:
+set(ASM_DIALECT "_NASM")
+include(CMakeASMInformation)
+set(ASM_DIALECT)
diff --git a/cmake/Modules/CMakeDetermineASM_NASMCompiler.cmake b/cmake/Modules/CMakeDetermineASM_NASMCompiler.cmake
new file mode 100644
index 000000000000..fb55d6e394be
--- /dev/null
+++ b/cmake/Modules/CMakeDetermineASM_NASMCompiler.cmake
@@ -0,0 +1,46 @@
+
+#=============================================================================
+# Copyright 2010 Kitware, Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+#   nor the names of their contributors may be used to endorse or promote
+#   products derived from this software without specific prior written
+#   permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+# Find the nasm assembler. yasm (http://www.tortall.net/projects/yasm/) is nasm compatible
+
+set(CMAKE_ASM_NASM_COMPILER_LIST nasm yasm)
+
+if(NOT CMAKE_ASM_NASM_COMPILER)
+  find_program(CMAKE_ASM_NASM_COMPILER nasm
+    "$ENV{ProgramFiles}/NASM")
+endif()
+
+# Load the generic DetermineASM compiler file with the DIALECT set properly:
+set(ASM_DIALECT "_NASM")
+include(CMakeDetermineASMCompiler)
+set(ASM_DIALECT)
diff --git a/cmake/Modules/CMakeTestASM_NASMCompiler.cmake b/cmake/Modules/CMakeTestASM_NASMCompiler.cmake
new file mode 100644
index 000000000000..987577335b90
--- /dev/null
+++ b/cmake/Modules/CMakeTestASM_NASMCompiler.cmake
@@ -0,0 +1,42 @@
+
+#=============================================================================
+# Copyright 2010 Kitware, Inc.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+#   nor the names of their contributors may be used to endorse or promote
+#   products derived from this software without specific prior written
+#   permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#=============================================================================
+
+# This file is used by EnableLanguage in cmGlobalGenerator to
+# determine that the selected ASM_NASM "compiler" works.
+# For assembler this can only check whether the compiler has been found,
+# because otherwise there would have to be a separate assembler source file
+# for each assembler on every architecture.
+
+set(ASM_DIALECT "_NASM")
+include(CMakeTestASMCompiler)
+set(ASM_DIALECT)
diff --git a/i386-unknown-freebsd7.2/srclists.cmake b/i386-unknown-freebsd7.2/srclists.cmake
index 501830fddeef..739fab589b43 100644
--- a/i386-unknown-freebsd7.2/srclists.cmake
+++ b/i386-unknown-freebsd7.2/srclists.cmake
@@ -602,6 +602,7 @@ set_property (SOURCE ${SRC}/dyninst/test_fork_11_mutatee.c APPEND PROPERTY COMPI
 set_property (SOURCE ${SRC}/dyninst/test_fork_11_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS GROUPABLE=0)
 set_property (SOURCE ${SRC}/symtab/test_anno_basic_types_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS TEST_NAME=test_anno_basic_types)
 set_property (SOURCE ${SRC}/symtab/test_anno_basic_types_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS GROUPABLE=1)
+set_property (SOURCE ${SRC}/dyninst/test6LS-x86.asm APPEND PROPERTY COMPILE_FLAGS -dPLATFORM=i386-unknown-freebsd7.2)
 set_property (SOURCE ${SRC}/dyninst/test1_4_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS TEST_NAME=test1_4)
 set_property (SOURCE ${SRC}/dyninst/test1_4_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS GROUPABLE=1)
 set_property (SOURCE ${SRC}/dyninst/test2_11_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS TEST_NAME=test2_11)
diff --git a/i386-unknown-linux2.4/srclists.cmake b/i386-unknown-linux2.4/srclists.cmake
index 1f8d7c8ed80d..a28b1e45d1bb 100644
--- a/i386-unknown-linux2.4/srclists.cmake
+++ b/i386-unknown-linux2.4/srclists.cmake
@@ -801,6 +801,7 @@ set_property (SOURCE ${SRC}/dyninst/test_fork_11_mutatee.c APPEND PROPERTY COMPI
 set_property (SOURCE ${SRC}/dyninst/test_fork_11_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS GROUPABLE=0)
 set_property (SOURCE ${SRC}/symtab/test_anno_basic_types_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS TEST_NAME=test_anno_basic_types)
 set_property (SOURCE ${SRC}/symtab/test_anno_basic_types_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS GROUPABLE=1)
+set_property (SOURCE ${SRC}/dyninst/test6LS-x86.asm APPEND PROPERTY COMPILE_FLAGS -dPLATFORM=i386-unknown-linux2.4)
 set_property (SOURCE ${SRC}/dyninst/test1_4_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS TEST_NAME=test1_4)
 set_property (SOURCE ${SRC}/dyninst/test1_4_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS GROUPABLE=1)
 set_property (SOURCE ${SRC}/dyninst/test2_11_mutatee.c APPEND PROPERTY COMPILE_DEFINITIONS TEST_NAME=test2_11)
diff --git a/src/specification/cmake_mutatees.py b/src/specification/cmake_mutatees.py
index 1b3817eca68e..f31946a096d5 100644
--- a/src/specification/cmake_mutatees.py
+++ b/src/specification/cmake_mutatees.py
@@ -247,6 +247,12 @@ def print_src_lists(mutatees, platform, info, directory):
                    (module, 
                     s, 
                     groupable))
+      elif (utils.extension(s) == ".asm" and
+            "nasm_asm" in platform["auxilliary_compilers"]):
+         out.write("set_property (SOURCE ${SRC}/%s/%s APPEND PROPERTY COMPILE_FLAGS -dPLATFORM=%s)\n" %
+                   (module,
+                    s,
+                    platform["name"]))
       # Skip raw sources; they don't need the GROUPABLE and TEST_NAMEs set
 
    out.close()
-- 
1.9.0

[← Prev in Thread] Current Thread [Next in Thread→]
  • [DynInst_API:] [PATCH] Enable ASM_NASM for i386 linux/freebsd, Josh Stone <=