Subject: [PATCH] cobol: Honor the "-static" command-line option.
[PR119231]

gcc/cobol/ChangeLog:

        PR cobol/119231
        * gcobolspec.cc: (lang_specific_driver): Pass OPT_static through.
        Handle -static and -static-libgcobol properly.

gcc/testsuite/ChangeLog:

        * cobol.dg/group2/_-static__compilation.cob: Modify for -static
warning.
        * cobol.dg/group2/_-static__compilation.out: Removed.
---
 gcc/cobol/gcobolspec.cc                             | 13 +++++++++++--
 .../cobol.dg/group2/_-static__compilation.cob       |  4 ++--
 .../cobol.dg/group2/_-static__compilation.out       |  2 --
 3 files changed, 13 insertions(+), 6 deletions(-)
 delete mode 100644
gcc/testsuite/cobol.dg/group2/_-static__compilation.out

diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc
index 038aaec1346..1f1b4631d8f 100644
--- a/gcc/cobol/gcobolspec.cc
+++ b/gcc/cobol/gcobolspec.cc
@@ -470,7 +470,10 @@ lang_specific_driver (struct cl_decoded_option
**in_decoded_options,
 ////        break;
 ////#endif
       case OPT_static:
+#if defined (HAVE_LD_STATIC_DYNAMIC)
+        append_arg(decoded_options[i]);
         static_in_general = true;
+#endif        
         break;
 
       default:
@@ -498,17 +501,23 @@ lang_specific_driver (struct cl_decoded_option
**in_decoded_options,
     need_libgcobol = false;
     }
 
+  if( static_in_general )
+    {
+    // These two options interfere with each other.
+    static_libgcobol = false;
+    }
+
   if( need_libgcobol )
     {
     add_arg_lib(COBOL_LIBRARY, static_libgcobol);
     }
   if( need_libdl )
     {
-    add_arg_lib(DL_LIBRARY, static_in_general);
+    add_arg_lib(DL_LIBRARY, false);
     }
   if( need_libstdc )
     {
-    add_arg_lib(STDCPP_LIBRARY, static_in_general);
+    add_arg_lib(STDCPP_LIBRARY, false);
     }
 
   if( prior_main )
diff --git a/gcc/testsuite/cobol.dg/group2/_-static__compilation.cob
b/gcc/testsuite/cobol.dg/group2/_-static__compilation.cob
index 7843d3d27aa..f344a84c398 100644
--- a/gcc/testsuite/cobol.dg/group2/_-static__compilation.cob
+++ b/gcc/testsuite/cobol.dg/group2/_-static__compilation.cob
@@ -1,7 +1,7 @@
        *> { dg-do run }
        *> { dg-options "-static" }
-       *> { dg-output-file "group2/_-static__compilation.out" }
-
+       *> { dg-prune-output {warning} }
+       *> { dg-output {hello, world} }
        IDENTIFICATION DIVISION.
        PROGRAM-ID. prog.
        PROCEDURE DIVISION.
diff --git a/gcc/testsuite/cobol.dg/group2/_-static__compilation.out
b/gcc/testsuite/cobol.dg/group2/_-static__compilation.out
deleted file mode 100644
index ae0e5111cae..00000000000
--- a/gcc/testsuite/cobol.dg/group2/_-static__compilation.out
+++ /dev/null
@@ -1,2 +0,0 @@
-hello, world
-
-- 
2.34.1

Reply via email to