Hi,

I have now tested to compile a scm file with -O0,  checked with objdump
that the dwarf information is gone and than load it and all seams fine.

diff is attached to this email

On Fri, May 19, 2017 at 9:10 PM, Stefan Israelsson Tampe <
stefan.ita...@gmail.com> wrote:

> I found a bug in the call-with-values part of the diff. That is fixed now
>
> On Fri, May 19, 2017 at 8:48 PM, Stefan Israelsson Tampe <
> stefan.ita...@gmail.com> wrote:
>
>> I manage to send the mail to fast. Here is the diff
>>
>> On Fri, May 19, 2017 at 8:46 PM, Stefan Israelsson Tampe <
>> stefan.ita...@gmail.com> wrote:
>>
>>> Hi,
>>>
>>> I've decided to start help developing guile. wingo has a list at
>>>
>>>    https://wingolog.org/archives/2016/02/04/guile-compiler-tasks
>>>
>>> I took, as a start, the first item: stripping binaries.
>>>
>>> one can remove debug information through
>>> guild compile -O0
>>>
>>> After some thought I think that the diff following this email adresses
>>> this, any comments are
>>> helpful else I will compile and start testing this option
>>>
>>
>>
>
diff --git a/module/language/cps/compile-bytecode.scm 
b/module/language/cps/compile-bytecode.scm
index c283eb6..a61849e 100644
--- a/module/language/cps/compile-bytecode.scm
+++ b/module/language/cps/compile-bytecode.scm
@@ -587,7 +587,9 @@
     (intmap-for-each (lambda (kfun body)
                        (compile-function (intmap-select exp body) asm))
                      (compute-reachable-functions exp 0))
-    (values (link-assembly asm #:page-aligned? (kw-arg-ref opts #:to-file? #f))
+    (values (link-assembly asm
+                           #:page-aligned? (kw-arg-ref opts #:to-file? #f)
+                           #:debug? (kw-arg-ref opts #:debug-info #t))
             env
             env)))
 
diff --git a/module/scripts/compile.scm b/module/scripts/compile.scm
index 939fb25..092c1d0 100644
--- a/module/scripts/compile.scm
+++ b/module/scripts/compile.scm
@@ -50,6 +50,7 @@
 
 (define (available-optimizations)
   (append (tree-il-default-optimization-options)
+          '(#:debug-info #t)
           (cps-default-optimization-options)))
 
 ;; Turn on all optimizations unless -O0.
@@ -57,6 +58,8 @@
   (let lp ((options (available-optimizations)))
     (match options
       (() '())
+      ((#:debug-info val . options)
+       (cons* #:debug-info (> level 0) (lp options)))
       ((#:partial-eval? val . options)
        (cons* #:partial-eval? (> level 0) (lp options)))
       ((kw val . options)
@@ -180,7 +183,8 @@ There is NO WARRANTY, to the extent permitted by law.~%"))
   (format #t "To disable an optimization, prepend it with `no-', for 
example~%")
   (format #t "`-Ono-cse.'~%~%")
   (format #t "You may also specify optimization levels as `-O0', `-O1',~%")
-  (format #t "`-O2', or `-O3'.  Currently `-O0' turns off all 
optimizations,~%")
+  (format #t "`-O2', or `-O3'.  Currently `-O0' turns off all optimizations~%")
+  (format #t "and remove all debug information,~%")
   (format #t "`-O1' turns on partial evaluation, and `-O2' and `-O3' turn 
on~%")
   (format #t "everything.  The default is equivalent to `-O2'.")
   (format #t "~%"))
@@ -217,7 +221,6 @@ Compile each Guile source file FILE into a Guile object.
                        for a list of available warnings
   -O, --optimize=OPT   specify optimization passes to run; use `-Ohelp'
                        for a list of available optimizations
-
   -f, --from=LANG      specify a source language other than `scheme'
   -t, --to=LANG        specify a target language other than `bytecode'
   -T, --target=TRIPLET produce bytecode for host TRIPLET
diff --git a/module/system/vm/assembler.scm b/module/system/vm/assembler.scm
index 8d71dc5..bf96d3b 100644
--- a/module/system/vm/assembler.scm
+++ b/module/system/vm/assembler.scm
@@ -2194,7 +2194,7 @@ procedure with label @var{rw-init}.  @var{rw-init} may be 
false.  If
 
 ;; The size of a procprops entry, in bytes.
 (define procprops-size 8)
-
+              
 (define (link-procprops asm)
   (define (assoc-remove-one alist key value-pred)
     (match alist
@@ -2575,7 +2575,7 @@ procedure with label @var{rw-init}.  @var{rw-init} may be 
false.  If
               (make-object asm '.debug_line bv line-relocs '()
                            #:type SHT_PROGBITS #:flags 0)))))
 
-(define (link-objects asm)
+(define* (link-objects asm debug?)
   (let*-values (;; Link procprops before constants, because it probably
                 ;; interns more constants.
                 ((procprops) (link-procprops asm))
@@ -2588,16 +2588,21 @@ procedure with label @var{rw-init}.  @var{rw-init} may 
be false.  If
                 ((symtab strtab) (link-symtab (linker-object-section text) 
asm))
                 ((arities arities-strtab) (link-arities asm))
                 ((docstrs docstrs-strtab) (link-docstrs asm))
-                ((dinfo dabbrev dstrtab dloc dline) (link-debug asm))
+                ((debug-tables)
+                 (values
+                  (if debug?
+                      (call-with-values (lambda () (link-debug asm)) list)
+                      '())))
                 ;; This needs to be linked last, because linking other
                 ;; sections adds entries to the string table.
                 ((shstrtab) (link-shstrtab asm)))
     (filter identity
-            (list text ro frame-maps rw dt symtab strtab
-                  arities arities-strtab
-                  docstrs docstrs-strtab procprops
-                  dinfo dabbrev dstrtab dloc dline
-                  shstrtab))))
+            (append
+             (list text ro frame-maps rw dt symtab strtab
+                   arities arities-strtab
+                   docstrs docstrs-strtab procprops)
+             debug-tables
+             (list shstrtab)))))
 
 
 
@@ -2606,9 +2611,10 @@ procedure with label @var{rw-init}.  @var{rw-init} may 
be false.  If
 ;;; High-level public interfaces.
 ;;;
 
-(define* (link-assembly asm #:key (page-aligned? #t))
+(define* (link-assembly asm #:key (page-aligned? #t) (debug? #t))
   "Produce an ELF image from the code and data emitted into @var{asm}.
 The result is a bytevector, by default linked so that read-only and
 writable data are on separate pages.  Pass @code{#:page-aligned? #f} to
-disable this behavior."
-  (link-elf (link-objects asm) #:page-aligned? page-aligned?))
+disable this behavior. Pass @code{debug? #f} to remove debug info from 
+the elf image"
+  (link-elf (link-objects asm debug?) #:page-aligned? page-aligned?))

Reply via email to