public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
@ 2020-06-08 14:24 dominiq at lps dot ens.fr
  2020-06-08 15:06 ` [Bug testsuite/95577] " iains at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-06-08 14:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

            Bug ID: 95577
           Summary: Tcl error with testsuite/gcc.misc-tests/outputs.exp on
                    darwin
           Product: gcc
           Version: 11.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: testsuite
          Assignee: unassigned at gcc dot gnu.org
          Reporter: dominiq at lps dot ens.fr
                CC: iains at gcc dot gnu.org
  Target Milestone: ---
              Host: x86_64-apple-darwin*
            Target: x86_64-apple-darwin*
             Build: x86_64-apple-darwin*

Running /opt/gcc/_clean/gcc/testsuite/gcc.misc-tests/outputs.exp ...
ERROR: tcl error sourcing
/opt/gcc/_clean/gcc/testsuite/gcc.misc-tests/outputs.exp.
ERROR: error deleting "a.out.dSYM": directory not empty
    while executing
"file delete $f"
    (procedure "outest" line 76)
    invoked from within
"outest "$b exe auxdump unnamed1" $sing "-g -fdump-rtl-final -fstack-usage
$gsplit_dwarf $oaout" {} {{a--0.c.???r.final a--0.su a--0.dwo $aout}}"
    (file "/opt/gcc/_clean/gcc/testsuite/gcc.misc-tests/outputs.exp" line 380)
    invoked from within
"source /opt/gcc/_clean/gcc/testsuite/gcc.misc-tests/outputs.exp"
    ("uplevel" body line 1)
    invoked from within
"uplevel #0 source /opt/gcc/_clean/gcc/testsuite/gcc.misc-tests/outputs.exp"
    invoked from within
"catch "uplevel #0 source $test_file_name""

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
@ 2020-06-08 15:06 ` iains at gcc dot gnu.org
  2020-06-09  7:36 ` iains at gcc dot gnu.org
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-08 15:06 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

Iain Sandoe <iains at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2020-06-08
     Ever confirmed|0                           |1
             Status|UNCONFIRMED                 |NEW
             Target|x86_64-apple-darwin*        |*-*-darwin*
               Host|x86_64-apple-darwin*        |*-*-darwin*
              Build|x86_64-apple-darwin*        |*-*-darwin*
   Target Milestone|---                         |11.0

--- Comment #1 from Iain Sandoe <iains at gcc dot gnu.org> ---
Darwin always separates debug info into a separate package (this is a directory
structure named exe.dSYM, for an exe name exe) [somewhat like split-dwarf, but
not optional or controlled by any command line flag]

This output is produced by the debug linker (dsymutil) any time that there is a
debug option on the command line + a source file, for which the object would be
temporary.

the failure mentioned occurs because the debug files are not being checked for
or deleted (and they are directory packages so that we need to use a suitable
delete).

this (first Part of the ) problem is fixed by the fragment below (Dominque's
patch + a tweak from me).

This then reveals a second issue - which is that the LTO tests are witten to
assume that the target generates thin LTO objects by default (which is true for
Linux but not for Darwin).  

The second problem can be catered for with a much longer patch which
essentially repeats the LTO tests for targets with/without fat-lto-objects. 
This seems a bit clunky and maybe there can be a better solution (maybe there
should also be a token test or two for linux using -ffat-lto-objects).

------

diff --git a/gcc/testsuite/gcc.misc-tests/outputs.exp
b/gcc/testsuite/gcc.misc-tests/outputs.exp
index 06a32dbeb9e..b3a1913f96c 100644
--- a/gcc/testsuite/gcc.misc-tests/outputs.exp
+++ b/gcc/testsuite/gcc.misc-tests/outputs.exp
@@ -43,6 +43,7 @@ if ![check_no_compiler_messages gsplitdwarf object {
 # Check for -flto support.  We explicitly test the result to skip
 # tests that use -flto.
 set skip_lto ![check_effective_target_lto]
+set target_lto_linker_plugin [check_linker_plugin_available]

 # Prepare additional options to be used for linking.
 # We do not compile to an executable, because that requires naming an output.
@@ -105,8 +106,12 @@ proc outest { test sources opts dirs outputs } {
        }
     }
     set options ""
+    set saw_debug 0
     foreach opt [split $opts " "] {
        append options " additional_flags=$opt"
+       if {[string match "-g*" "$opt"]} {
+           set saw_debug 1
+       }
     }
     # Add linker flags if we're linking
     if {![string match "* -\[ESc\] *" " $opts "]} {
@@ -143,6 +148,12 @@ proc outest { test sources opts dirs outputs } {
            if { [file exists $d$o] } then {
                pass "$test: $d$o"
                file delete $d$o
+               if { $saw_debug && [file exists $d$o.dSYM]} {
+                   # Darwin split debug directory packages, expected for
+                   # any case where debug is enabled for a single-file
+                   # test.
+                   file delete -force $d$o.dSYM
+               }
            } else {
                set ogl [glob -nocomplain -path $d -- $o]
                if { $ogl != {} } {

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
  2020-06-08 15:06 ` [Bug testsuite/95577] " iains at gcc dot gnu.org
@ 2020-06-09  7:36 ` iains at gcc dot gnu.org
  2020-06-23 11:17 ` aoliva at gcc dot gnu.org
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-09  7:36 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

--- Comment #2 from Iain Sandoe <iains at gcc dot gnu.org> ---
Created attachment 48710
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=48710&action=edit
hacky patch that fixes the output for fat and thin LTO

This is pretty non-elegant - essentially duplicating the LTO tests for the FAT
and THIN LTO cases, since the expected file list differs by the .final outputs
for the FAT case.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
  2020-06-08 15:06 ` [Bug testsuite/95577] " iains at gcc dot gnu.org
  2020-06-09  7:36 ` iains at gcc dot gnu.org
@ 2020-06-23 11:17 ` aoliva at gcc dot gnu.org
  2020-06-23 11:45 ` iains at gcc dot gnu.org
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2020-06-23 11:17 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |aoliva at gcc dot gnu.org
             Status|NEW                         |ASSIGNED
           Assignee|unassigned at gcc dot gnu.org      |aoliva at gcc dot gnu.org

--- Comment #3 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Iain,

Do platforms that use dsymutil support -gsplit-dwarf?

I'm thinking of bringing -g into the gsplit_dwarf variable, so it won't be
enable without -gsplit-dwarf, and removing other explicit mentions of -g from
outputs.exp.

Would this be enough to address the dsymutil left-overs?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
                   ` (2 preceding siblings ...)
  2020-06-23 11:17 ` aoliva at gcc dot gnu.org
@ 2020-06-23 11:45 ` iains at gcc dot gnu.org
  2020-06-23 13:16 ` aoliva at gcc dot gnu.org
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-23 11:45 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Alexandre Oliva from comment #3)
> Iain,
> 
> Do platforms that use dsymutil support -gsplit-dwarf?

None I am aware of - Darwin should reject -gsplit-dwarf with a diagnostic, so
that configuration should detect missing support correctly there.

> I'm thinking of bringing -g into the gsplit_dwarf variable, so it won't be
> enable without -gsplit-dwarf, and removing other explicit mentions of -g
> from outputs.exp.
> 
> Would this be enough to address the dsymutil left-overs?

I don't think so (hence the code to detect -g* and delete the .dSYM if one is
seen).

======

The motivation for Darwin's 'split' debug is actually different from the
-gsplit-dwarf (and it doesn't solve the object size problem that split dwarf
does).

For the record - the Darwin behaviour is like this;

[when debug is enabled] the static linker [ld64] embeds a list of contributing
object file paths into the executable.  It does not link or include any debug
in the exe (this saves time).

dsymutil [the debug linker] takes the executable, looks up the list of object
files and produces a linked debug object, this is placed into a Darwin file
package (a directory structure with some metadata embedded + the object).  This
is named <exe>.dSYM <= but it's a file package, so has to be deleted like a
directory.

On Darwin, debug consumers have two options;

1. Use the table in the exe to pull the debug data directly from the
contributing objects (i.e. never do an actual debug link but just dynamically
satisfy those symbols the user inspects).
  - LLDB and GDB both grok this (newer GDBs might have bit-rotted somewhat
since Adacore is no longer maintaining the Darwin binutils stuff and I am
totally out of cycles to contribute).

2. If the the debug linker has been run and the .dSYM is available, they can
use that.

1) is very efficient for large projects with many object files with long debug
link times, since that stage of linking can be omitted in the
compile/edit/debug loop.

-----

BUT, then there's one case where (1) doesn't work - which is when the user
does;

 gcc foo.c bar.o ..... -g -o x

because the object file created for any source on the command line is
ephemeral, and thus if it's put into the exe that doesn't help - because it
won't be available at debug time.

So Darwin's linker spec force dsymutil to be run for any compile line that
includes a source file, this is a very common circumstance in the test suite,
leading to many .dSYM files that need to be removed.

The patch fragment at comment #1 addresses this for these tests (and Dominque
has a larger patch [which I need to look at] to clean it up in more places in
the test suite).

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
                   ` (3 preceding siblings ...)
  2020-06-23 11:45 ` iains at gcc dot gnu.org
@ 2020-06-23 13:16 ` aoliva at gcc dot gnu.org
  2020-06-23 13:31 ` iains at gcc dot gnu.org
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2020-06-23 13:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

--- Comment #5 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
but is .dSYM ever generated when no -g is present?

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
                   ` (4 preceding siblings ...)
  2020-06-23 13:16 ` aoliva at gcc dot gnu.org
@ 2020-06-23 13:31 ` iains at gcc dot gnu.org
  2020-06-23 13:58 ` aoliva at gcc dot gnu.org
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: iains at gcc dot gnu.org @ 2020-06-23 13:31 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

--- Comment #6 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Alexandre Oliva from comment #5)
> but is .dSYM ever generated when no -g is present?

If it was that would e an error, so correctly would cause the test to fail.

That's why I was doing:
   if {[string match "-g*" "$opt"]} {
     set saw_debug 1
   }

If you are going to remove all debug tests, then the .dSYM case would not be
needed indeed

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
                   ` (5 preceding siblings ...)
  2020-06-23 13:31 ` iains at gcc dot gnu.org
@ 2020-06-23 13:58 ` aoliva at gcc dot gnu.org
  2020-06-23 16:42 ` dominiq at lps dot ens.fr
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2020-06-23 13:58 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                URL|                            |https://gcc.gnu.org/piperma
                   |                            |il/gcc-patches/2020-June/54
                   |                            |8730.html

--- Comment #7 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Proposed fix at https://gcc.gnu.org/pipermail/gcc-patches/2020-June/548730.html

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
                   ` (6 preceding siblings ...)
  2020-06-23 13:58 ` aoliva at gcc dot gnu.org
@ 2020-06-23 16:42 ` dominiq at lps dot ens.fr
  2020-06-24 20:24 ` cvs-commit at gcc dot gnu.org
  2020-06-24 20:41 ` aoliva at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: dominiq at lps dot ens.fr @ 2020-06-23 16:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

--- Comment #8 from Dominique d'Humieres <dominiq at lps dot ens.fr> ---
> Proposed fix at https://gcc.gnu.org/pipermail/gcc-patches/2020-June/548730.html

Seems to work for me. Thanks!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
                   ` (7 preceding siblings ...)
  2020-06-23 16:42 ` dominiq at lps dot ens.fr
@ 2020-06-24 20:24 ` cvs-commit at gcc dot gnu.org
  2020-06-24 20:41 ` aoliva at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2020-06-24 20:24 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

--- Comment #9 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Alexandre Oliva <aoliva@gcc.gnu.org>:

https://gcc.gnu.org/g:ef6506e23691a72e1e724977e8ee8b9f3db74015

commit r11-1642-gef6506e23691a72e1e724977e8ee8b9f3db74015
Author: Alexandre Oliva <oliva@adacore.com>
Date:   Wed Jun 24 17:20:49 2020 -0300

    outputs.exp: conditionals for split-dwarf and lto plugin

    This patch introduces support for conditionals (and expr) expansions
    to file lists in proc outest in outputs.exp.

    The conditionals machinery is now used to guard files that are only
    created by the LTO plugin, or when not using the LTO plugin.

    It is also used to avoid special-casing .dwo files: the condition of
    when they're expected is now encoded in the list.

    Furthermore, the -g flag, that used to be specified along with
    $gsplit_dwarf, is now moved into $gsplit_dwarf, so that we don't
    compile with -g if -gsplit-dwarf is not needed.  This avoids having to
    deal with .dSYM directories.

    Further removing special cases, $aout is now dealt with in a more
    general way, using expr to perform variable/string expansion.


    for  gcc/testsuite/ChangeLog

            PR testsuite/95416
            PR testsuite/95577
            * gcc.misc-tests/outputs.exp (gsplit_dwarf): Move -g into it.
            (outest): Introduce conditionals and string/variable/expr
            expansion.  Drop special-casing of $aout and .dwo.
            (gspd): New conditional.  Guard all .dwo files with it.
            (ltop): New conditional.  Guard files created by the LTO
            plugin with it.  Guard files created by fat LTO compilation
            with its negation.  Add a few -fno-use-linker-plugin tests
            guarded by it.

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [Bug testsuite/95577] Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin
  2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
                   ` (8 preceding siblings ...)
  2020-06-24 20:24 ` cvs-commit at gcc dot gnu.org
@ 2020-06-24 20:41 ` aoliva at gcc dot gnu.org
  9 siblings, 0 replies; 11+ messages in thread
From: aoliva at gcc dot gnu.org @ 2020-06-24 20:41 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95577

Alexandre Oliva <aoliva at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Resolution|---                         |FIXED
             Status|ASSIGNED                    |RESOLVED

--- Comment #10 from Alexandre Oliva <aoliva at gcc dot gnu.org> ---
Fixed

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2020-06-24 20:41 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-08 14:24 [Bug testsuite/95577] New: Tcl error with testsuite/gcc.misc-tests/outputs.exp on darwin dominiq at lps dot ens.fr
2020-06-08 15:06 ` [Bug testsuite/95577] " iains at gcc dot gnu.org
2020-06-09  7:36 ` iains at gcc dot gnu.org
2020-06-23 11:17 ` aoliva at gcc dot gnu.org
2020-06-23 11:45 ` iains at gcc dot gnu.org
2020-06-23 13:16 ` aoliva at gcc dot gnu.org
2020-06-23 13:31 ` iains at gcc dot gnu.org
2020-06-23 13:58 ` aoliva at gcc dot gnu.org
2020-06-23 16:42 ` dominiq at lps dot ens.fr
2020-06-24 20:24 ` cvs-commit at gcc dot gnu.org
2020-06-24 20:41 ` aoliva at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).