I manage to send the mail to fast. Here is the diff
On Fri, May 19, 2017 at 8:46 PM, Stefan Israelsson Tampe <
[email protected]> 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..56acef0 100644
--- a/module/scripts/compile.scm
+++ b/module/scripts/compile.scm
@@ -108,7 +108,10 @@
((string=? arg "help")
(show-optimization-help)
(exit 0))
- ((equal? arg "0") (return (optimizations-for-level 0)))
+ ((equal? arg "0")
+ (alist-cons
+ #:debug-info #f
+ (return (optimizations-for-level 0))))
((equal? arg "1") (return (optimizations-for-level 1)))
((equal? arg "2") (return (optimizations-for-level 2)))
((equal? arg "3") (return (optimizations-for-level 3)))
@@ -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..4642d09 100644
--- a/module/system/vm/assembler.scm
+++ b/module/system/vm/assembler.scm
@@ -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 list (link-debug asm))
+ '())))
;; 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?))