mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-04-30 03:40:34 +02:00
Wire up simplified warning levels in "guild compile"
* am/guilec (GUILE_WARNINGS): * am/bootstrap.am (GUILE_WARNINGS): Explictly default to -W1. * bootstrap/Makefile.am (GUILE_WARNINGS): Set to -Wnone, as the meaning of "no -W flags" has changed to be effectively -W1. * module/scripts/compile.scm (%options): Adapt to parse -Wnone, -W2, and so on. (parse-args): Default to (default-warning-level). (show-warning-help): Add more warning help. (compile): Pass #:warning-level.
This commit is contained in:
parent
116f94d661
commit
220934c49d
4 changed files with 35 additions and 15 deletions
|
@ -18,7 +18,7 @@
|
||||||
## Fifth Floor, Boston, MA 02110-1301 USA
|
## Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
# These variables can be set before you include bootstrap.am.
|
# These variables can be set before you include bootstrap.am.
|
||||||
GUILE_WARNINGS ?= -Wunbound-variable -Warity-mismatch -Wformat
|
GUILE_WARNINGS ?= -W1
|
||||||
GUILE_OPTIMIZATIONS ?= -O2
|
GUILE_OPTIMIZATIONS ?= -O2
|
||||||
GUILE_TARGET ?= $(host)
|
GUILE_TARGET ?= $(host)
|
||||||
GUILE_BUILD_TAG ?= BOOTSTRAP
|
GUILE_BUILD_TAG ?= BOOTSTRAP
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
# -*- makefile -*-
|
# -*- makefile -*-
|
||||||
GOBJECTS = $(SOURCES:%.scm=%.go) $(ELISP_SOURCES:%.el=%.go)
|
GOBJECTS = $(SOURCES:%.scm=%.go) $(ELISP_SOURCES:%.el=%.go)
|
||||||
|
|
||||||
GUILE_WARNINGS = -Wunbound-variable -Wmacro-use-before-definition -Warity-mismatch -Wformat
|
GUILE_WARNINGS = -W1
|
||||||
|
|
||||||
moddir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)/$(modpath)
|
moddir = $(pkgdatadir)/$(GUILE_EFFECTIVE_VERSION)/$(modpath)
|
||||||
nobase_mod_DATA = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
|
nobase_mod_DATA = $(SOURCES) $(ELISP_SOURCES) $(NOCOMP_SOURCES)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
## Process this file with automake to produce Makefile.in.
|
## Process this file with automake to produce Makefile.in.
|
||||||
##
|
##
|
||||||
## Copyright (C) 2009, 2010, 2011, 2012, 2013,
|
## Copyright (C) 2009, 2010, 2011, 2012, 2013,
|
||||||
## 2014, 2015, 2018 Free Software Foundation, Inc.
|
## 2014, 2015, 2018, 2020 Free Software Foundation, Inc.
|
||||||
##
|
##
|
||||||
## This file is part of GUILE.
|
## This file is part of GUILE.
|
||||||
##
|
##
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
## Fifth Floor, Boston, MA 02110-1301 USA
|
## Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
|
||||||
|
|
||||||
GUILE_WARNINGS =
|
GUILE_WARNINGS = -Wnone
|
||||||
# Loading eval.go happens before boot and therefore before modules are
|
# Loading eval.go happens before boot and therefore before modules are
|
||||||
# resolved. For some reason if compiled without resolve-primitives,
|
# resolved. For some reason if compiled without resolve-primitives,
|
||||||
# attempts to resolve primitives at boot fail; weird. Should fix this
|
# attempts to resolve primitives at boot fail; weird. Should fix this
|
||||||
|
|
|
@ -30,7 +30,9 @@
|
||||||
|
|
||||||
(define-module (scripts compile)
|
(define-module (scripts compile)
|
||||||
#:use-module ((system base language) #:select (lookup-language))
|
#:use-module ((system base language) #:select (lookup-language))
|
||||||
#:use-module ((system base compile) #:select (compile-file))
|
#:use-module ((system base compile) #:select (compile-file
|
||||||
|
default-warning-level
|
||||||
|
default-optimization-level))
|
||||||
#:use-module (system base target)
|
#:use-module (system base target)
|
||||||
#:use-module (system base message)
|
#:use-module (system base message)
|
||||||
#:use-module (system base optimize)
|
#:use-module (system base optimize)
|
||||||
|
@ -81,14 +83,27 @@
|
||||||
|
|
||||||
(option '(#\W "warn") #t #f
|
(option '(#\W "warn") #t #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
(if (string=? arg "help")
|
(match arg
|
||||||
(begin
|
("help"
|
||||||
(show-warning-help)
|
(show-warning-help)
|
||||||
(exit 0))
|
(exit 0))
|
||||||
(let ((warnings (assoc-ref result 'warnings)))
|
("all"
|
||||||
(alist-cons 'warnings
|
(alist-cons 'warning-level #t
|
||||||
(cons (string->symbol arg) warnings)
|
(alist-delete 'warning-level result)))
|
||||||
(alist-delete 'warnings result))))))
|
("none"
|
||||||
|
(alist-cons 'warning-level #f
|
||||||
|
(alist-delete 'warning-level result)))
|
||||||
|
((? string->number)
|
||||||
|
(let ((n (string->number arg)))
|
||||||
|
(unless (and (exact-integer? n) (<= 0 n))
|
||||||
|
(fail "Bad warning level `~a'" n))
|
||||||
|
(alist-cons 'warning-level n
|
||||||
|
(alist-delete 'warning-level result))))
|
||||||
|
(_
|
||||||
|
(let ((warnings (assoc-ref result 'warnings)))
|
||||||
|
(alist-cons 'warnings
|
||||||
|
(cons (string->symbol arg) warnings)
|
||||||
|
(alist-delete 'warnings result)))))))
|
||||||
|
|
||||||
(option '(#\O "optimize") #t #f
|
(option '(#\O "optimize") #t #f
|
||||||
(lambda (opt name arg result)
|
(lambda (opt name arg result)
|
||||||
|
@ -141,8 +156,9 @@ options."
|
||||||
result)))
|
result)))
|
||||||
|
|
||||||
;; default option values
|
;; default option values
|
||||||
'((input-files)
|
`((input-files)
|
||||||
(load-path)
|
(load-path)
|
||||||
|
(warning-level . ,(default-warning-level))
|
||||||
(warnings unsupported-warning))))
|
(warnings unsupported-warning))))
|
||||||
|
|
||||||
(define (show-version)
|
(define (show-version)
|
||||||
|
@ -159,7 +175,9 @@ There is NO WARRANTY, to the extent permitted by law.~%"))
|
||||||
(format #f "`~A'" (warning-type-name wt))
|
(format #f "`~A'" (warning-type-name wt))
|
||||||
(warning-type-description wt)))
|
(warning-type-description wt)))
|
||||||
%warning-types)
|
%warning-types)
|
||||||
(format #t "~%"))
|
(format #t "~%")
|
||||||
|
(format #t "You may also specify warning levels as `-Wnone', `-W0`, `-W1',~%")
|
||||||
|
(format #t "`-W2', `-W3', or `-Wall`. The default is `-W1'.~%"))
|
||||||
|
|
||||||
(define (show-optimization-help)
|
(define (show-optimization-help)
|
||||||
(format #t "The available optimizations are:~%~%")
|
(format #t "The available optimizations are:~%~%")
|
||||||
|
@ -184,6 +202,7 @@ There is NO WARRANTY, to the extent permitted by law.~%"))
|
||||||
(define (compile . args)
|
(define (compile . args)
|
||||||
(let* ((options (parse-args args))
|
(let* ((options (parse-args args))
|
||||||
(help? (assoc-ref options 'help?))
|
(help? (assoc-ref options 'help?))
|
||||||
|
(warning-level (assoc-ref options 'warning-level))
|
||||||
(compile-opts `(#:warnings
|
(compile-opts `(#:warnings
|
||||||
,(assoc-ref options 'warnings)
|
,(assoc-ref options 'warnings)
|
||||||
,@(append-map
|
,@(append-map
|
||||||
|
@ -266,6 +285,7 @@ Report bugs to <~A>.~%"
|
||||||
#:output-file output-file
|
#:output-file output-file
|
||||||
#:from from
|
#:from from
|
||||||
#:to to
|
#:to to
|
||||||
|
#:warning-level warning-level
|
||||||
#:opts compile-opts))))))
|
#:opts compile-opts))))))
|
||||||
input-files)))
|
input-files)))
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue