This patch introduces a CUSTOM_LDSCRIPTS variable in the Makefile as
preparation for enabling libhugetlbfs linking on architectures w/o providing
(deprecated) custom linker scripts. Setting it to "no" will prevent building
and running the test cases requiring custom linker scripts, and issue an
error message in ld.hugetlbfs when option --hugetlbfs-link is being used.
It is set to "yes" by default for all architectures, which means no change
to the current behaviour as far as "make" is concerned.

A new option -l is added to run_tests.py, enabling the old-style linking
tests. This means that the default for running run_tests.py directly is
now changed to skip the old-style linking tests.

Signed-off-by: Gerald Schaefer <gerald.schae...@de.ibm.com>
---
 Makefile           | 17 ++++++++++++-----
 ld.hugetlbfs       | 11 +++++++++++
 tests/Makefile     | 10 ++++++++++
 tests/run_tests.py | 19 +++++++++++++++----
 4 files changed, 48 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index 03966b2..3ec3c15 100644
--- a/Makefile
+++ b/Makefile
@@ -34,6 +34,8 @@ CPPFLAGS += -D__LIBHUGETLBFS__
 
 ARCH = $(shell uname -m | sed -e s/i.86/i386/)
 
+CUSTOM_LDSCRIPTS = yes
+
 ifeq ($(ARCH),ppc64)
 CC64 = gcc -m64
 ELF64 = elf64ppc
@@ -128,6 +130,10 @@ LIB64 = $(TMPLIB64)
 endif
 endif
 
+ifeq ($(CUSTOM_LDSCRIPTS),yes)
+TEST_LDSCRIPTS = -l
+endif
+
 # If TMPLIB64 is set, then sure we are not resolving LIB32 and LIB64 to the
 # same place
 ifdef TMPLIB64
@@ -187,6 +193,7 @@ export ELF32
 export ELF64
 export LIBDIR32
 export LIBDIR64
+export CUSTOM_LDSCRIPTS
 
 all:   libs tests tools
 
@@ -203,16 +210,16 @@ tests/%: libs
 tools:  $(foreach file,$(INSTALL_BIN),$(BIN_OBJ_DIR)/$(file))
 
 check: all
-       cd tests; ./run_tests.py
+       cd tests; ./run_tests.py $(TEST_LDSCRIPTS)
 
 checkv:        all
-       cd tests; ./run_tests.py -vV
+       cd tests; ./run_tests.py -vV $(TEST_LDSCRIPTS)
 
 func:  all
-       cd tests; ./run_tests.py -t func
+       cd tests; ./run_tests.py -t func $(TEST_LDSCRIPTS)
 
 funcv: all
-       cd tests; ./run_tests.py -t func -vV
+       cd tests; ./run_tests.py -t func -vV $(TEST_LDSCRIPTS)
 
 stress:        all
        cd tests; ./run_tests.py -t stress
@@ -365,7 +372,7 @@ obj64/install:
 
 objscript.%: %
        @$(VECHO) OBJSCRIPT $*
-       sed "s!### SET DEFAULT LDSCRIPT PATH HERE 
###!HUGETLB_LDSCRIPT_PATH=$(LDSCRIPTDIR)!" < $< > $@
+       sed "s!### SET DEFAULT LDSCRIPT PATH HERE 
###!HUGETLB_LDSCRIPT_PATH=$(LDSCRIPTDIR)!;s!### SET CUSTOM_LDSCRIPTS HERE 
###!CUSTOM_LDSCRIPTS=\"$(CUSTOM_LDSCRIPTS)\"!" < $< > $@
 
 install-libs: libs $(OBJDIRS:%=%/install) $(INSTALL_OBJSCRIPT:%=objscript.%)
        $(INSTALL) -d $(DESTDIR)$(HEADERDIR)
diff --git a/ld.hugetlbfs b/ld.hugetlbfs
index d102a56..aa25242 100755
--- a/ld.hugetlbfs
+++ b/ld.hugetlbfs
@@ -14,6 +14,13 @@ if [ -z "$HUGETLB_LDSCRIPT_PATH" ]; then
     HUGETLB_LDSCRIPT_PATH=$(dirname $(readlink $0))/ldscripts
 fi
 
+### SET CUSTOM_LDSCRIPTS HERE ###
+if [ -z "$CUSTOM_LDSCRIPTS" ]; then
+    # Assume this script is running from the libhugetlbfs source tree,
+    # and set CUSTOM_LDSCRIPTS to default "yes"
+    CUSTOM_LDSCRIPTS="yes"
+fi
+
 # Try to figure out what's the underlying linker to invoke
 if [ -z "$LD" ]; then
     for x in $(which -a ld); do
@@ -65,6 +72,10 @@ while [ -n "$1" ]; do
 done
 
 if [ -n "$HTLB_LINK" ]; then
+    if [ "$CUSTOM_LDSCRIPTS" == "no" ]; then
+        echo -n "ld.hugetlbfs: --hugetlbfs-link is not supported on this " 1>&2
+        echo "platform. Use --hugetlbfs-align instead." 1>&2
+    fi
     HTLB_ALIGN="" # --hugetlbfs-link overrides --hugetlbfs-align
     LDSCRIPT="$EMU.x$HTLB_LINK"
     HTLBOPTS="-T${HUGETLB_LDSCRIPT_PATH}/${LDSCRIPT}"
diff --git a/tests/Makefile b/tests/Makefile
index 596ce72..231e3b0 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -41,12 +41,22 @@ INSTALL = install
 
 TESTS = $(LIB_TESTS) $(NOLIB_TESTS) $(STRESS_TESTS) dummy.ldscript
 ifdef ELF32
+ifeq ($(CUSTOM_LDSCRIPTS),yes)
 TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_TESTS:%=xB.%) \
        $(HUGELINK_TESTS:%=xBDT.%) $(HUGELINK_RW_TESTS)
 else
+TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_RW_TESTS)
+endif
+
+else
 ifdef ELF64
+ifeq ($(CUSTOM_LDSCRIPTS),yes)
 TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS) $(HUGELINK_TESTS:%=xB.%) \
        $(HUGELINK_TESTS:%=xBDT.%)
+else
+TESTS += $(LDSCRIPT_TESTS) $(HUGELINK_TESTS)
+endif
+
 endif
 endif
 
diff --git a/tests/run_tests.py b/tests/run_tests.py
index c1564c7..c060699 100755
--- a/tests/run_tests.py
+++ b/tests/run_tests.py
@@ -377,6 +377,11 @@ def elflink_test(cmd, **env):
     do_test(cmd, **env)
     # Test we don't blow up if not linked for hugepage
     do_test(cmd, LD_PRELOAD="libhugetlbfs.so", **env)
+
+    # Only run custom ldscript tests when -l option is set
+    if not custom_ldscripts:
+        return
+
     do_elflink_test("xB." + cmd, **env)
     do_elflink_test("xBDT." + cmd, **env)
     # Test we don't blow up if HUGETLB_MINIMAL_COPY is diabled
@@ -578,9 +583,11 @@ def functional_tests():
     elflink_test("linkhuge_nofd", HUGETLB_VERBOSE="0")
     elflink_test("linkhuge")
 
-    # Original elflink sharing tests
-    elfshare_test("linkshare")
-    elflink_and_share_test("linkhuge")
+    # Only run custom ldscript tests when -l option is set
+    if custom_ldscripts:
+        # Original elflink sharing tests
+        elfshare_test("linkshare")
+        elflink_and_share_test("linkhuge")
 
     # elflink_rw tests
     elflink_rw_test("linkhuge_rw")
@@ -645,15 +652,17 @@ def stress_tests():
 
 def main():
     global wordsizes, pagesizes, dangerous, paranoid_pool_check, 
system_default_hpage_size
+    global custom_ldscripts
     testsets = set()
     env_override = {"QUIET_TEST": "1", "HUGETLBFS_MOUNTS": "",
                     "HUGETLB_ELFMAP": None, "HUGETLB_MORECORE": None}
     env_defaults = {"HUGETLB_VERBOSE": "0"}
     dangerous = 0
     paranoid_pool_check = False
+    custom_ldscripts = False
 
     try:
-        opts, args = getopt.getopt(sys.argv[1:], "vVfdt:b:p:c")
+        opts, args = getopt.getopt(sys.argv[1:], "vVfdt:b:p:c:l")
     except getopt.GetoptError, err:
         print str(err)
         sys.exit(1)
@@ -673,6 +682,8 @@ def main():
            for p in arg.split(): pagesizes.add(int(p))
        elif opt == '-c':
            paranoid_pool_check = True
+       elif opt == '-l':
+           custom_ldscripts = True
        else:
            assert False, "unhandled option"
     if len(testsets) == 0: testsets = set(["func", "stress"])
-- 
1.7.12.4


------------------------------------------------------------------------------
Everyone hates slow websites. So do we.
Make your web apps faster with AppDynamics
Download AppDynamics Lite for free today:
http://p.sf.net/sfu/appdyn_d2d_nov
_______________________________________________
Libhugetlbfs-devel mailing list
Libhugetlbfs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/libhugetlbfs-devel

Reply via email to