]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
cobol: Honor the "-static" command-line option. [PR119231]
authorRobert Dubner <rdubner@symas.com>
Thu, 24 Jul 2025 16:09:36 +0000 (12:09 -0400)
committerRobert Dubner <rdubner@symas.com>
Tue, 29 Jul 2025 16:06:40 +0000 (12:06 -0400)
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.

(cherry picked from commit 44e32178031e89399710c3ee7444891631a9c8ec)

gcc/cobol/gcobolspec.cc
gcc/testsuite/cobol.dg/group2/_-static__compilation.cob
gcc/testsuite/cobol.dg/group2/_-static__compilation.out [deleted file]

index 9532d4256b22c466d0251a63610171608f3467e1..2f3092da5d8520e3869fef97f1e5a6ab102fcc40 100644 (file)
@@ -478,7 +478,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:
@@ -506,17 +509,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 )
index 7843d3d27aac0066547bc47d8cd3d5f6c9d5e251..f344a84c3988da02968964a5d65fdf23d520493a 100644 (file)
@@ -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 (file)
index ae0e511..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-hello, world
-