https://gcc.gnu.org/g:827a1471666de2fff8799c3bcd5f54ab24caba80

commit r15-8660-g827a1471666de2fff8799c3bcd5f54ab24caba80
Author: Iain Sandoe <i...@sandoe.co.uk>
Date:   Fri Mar 21 15:14:19 2025 +0000

    cobol, driver: Handle targets without HAVE_LD_STATIC_DYNAMIC.
    
    This fixes a typo where libraries were not added for targets without
    HAVE_LD_STATIC_DYNAMIC.
    
    It also adds the libraries in this case;
    typically, a target without HAVE_LD_STATIC_DYNAMIC can take the
    -static-libgcobol and use that to drive a spec substitution viz:
     %{static-libgcobol:%:replace-outfile(-lgcobol libgcobol.a%s)}
    which needs both the library and -static-libgcobol to be present
    in the driver output.
    
    gcc/cobol/ChangeLog:
    
            * gcobolspec.cc (add_arg_lib): Fix typo.
            (lang_specific_driver): Arrange to append both -lgcobol
            and -static-libgcobol for targets without
            HAVE_LD_STATIC_DYNAMIC.
    
    Signed-off-by: Iain Sandoe <i...@sandoe.co.uk>

Diff:
---
 gcc/cobol/gcobolspec.cc | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/gcc/cobol/gcobolspec.cc b/gcc/cobol/gcobolspec.cc
index 4ae8e2cfd9e4..7de41fd037a3 100644
--- a/gcc/cobol/gcobolspec.cc
+++ b/gcc/cobol/gcobolspec.cc
@@ -116,8 +116,8 @@ add_arg_lib(const char *library, bool force_static 
ATTRIBUTE_UNUSED)
     {
     append_option (OPT_Wl_, LD_STATIC_OPTION, 1);
     }
-  append_option (OPT_l, library, 1);
 #endif
+  append_option (OPT_l, library, 1);
 #ifdef HAVE_LD_STATIC_DYNAMIC
   if( force_static )
     {
@@ -339,10 +339,8 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
         break;
 
       case OPT_static_libgcobol:
-#ifdef HAVE_LD_STATIC_DYNAMIC
         static_libgcobol = true;
         need_libgcobol   = true;
-#endif
         break;
 
       case OPT_l:
@@ -548,7 +546,11 @@ lang_specific_driver (struct cl_decoded_option 
**in_decoded_options,
         break;
 
       case OPT_static_libgcobol:
-        // Don't pass this one on to cobol1
+#if !defined (HAVE_LD_STATIC_DYNAMIC)
+        // Allow the target to use spec substitution.
+        append_arg(decoded_options[i]);
+#endif
+        // Else don't pass this one on to cobol1
         break;
 
 ////#ifdef __x86_64__

Reply via email to