https://gcc.gnu.org/g:44e32178031e89399710c3ee7444891631a9c8ec

commit r16-2489-g44e32178031e89399710c3ee7444891631a9c8ec
Author: Robert Dubner <rdub...@symas.com>
Date:   Thu Jul 24 12:09:36 2025 -0400

    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.

Diff:
---
 gcc/cobol/gcobolspec.cc                                 | 13 +++++++++++--
 gcc/testsuite/cobol.dg/group2/_-static__compilation.cob |  4 ++--
 gcc/testsuite/cobol.dg/group2/_-static__compilation.out |  2 --
 3 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc
index 038aaec13469..1f1b4631d8f3 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 7843d3d27aac..f344a84c3988 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 ae0e5111caef..000000000000
--- a/gcc/testsuite/cobol.dg/group2/_-static__compilation.out
+++ /dev/null
@@ -1,2 +0,0 @@
-hello, world
-

Reply via email to