From: Ken Brown Date: Sun, 26 Mar 2023 19:02:30 +0000 (-0400) Subject: Enable ASLR for dynamic libraries on Cygwin X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=66b4394461589d0db8690b7971000f687bd3ad57;p=emacs.git Enable ASLR for dynamic libraries on Cygwin This seems to avoid the fork failures described in etc/PROBLEMS ("Fork failures in a build with native compilation"). * lisp/treesit.el (treesit--install-language-grammar-1): * lisp/emacs-lisp/comp.el (native-comp-driver-options): Add the linker flag "-Wl,-dynamicbase" on Cygwin. --- diff --git a/lisp/emacs-lisp/comp.el b/lisp/emacs-lisp/comp.el index 7d9832f588f..3c57ca79b12 100644 --- a/lisp/emacs-lisp/comp.el +++ b/lisp/emacs-lisp/comp.el @@ -186,8 +186,9 @@ and above." :type '(repeat string) :version "28.1") -(defcustom native-comp-driver-options (when (eq system-type 'darwin) - '("-Wl,-w")) +(defcustom native-comp-driver-options + (cond ((eq system-type 'darwin) '("-Wl,-w")) + ((eq system-type 'cygwin) '("-Wl,-dynamicbase"))) "Options passed verbatim to the native compiler's back-end driver. Note that not all options are meaningful; typically only the options affecting the assembler and linker are likely to be useful. diff --git a/lisp/treesit.el b/lisp/treesit.el index 2b0eca7f5c2..e3c7d569ea6 100644 --- a/lisp/treesit.el +++ b/lisp/treesit.el @@ -3056,11 +3056,17 @@ function signals an error." (apply #'treesit--call-process-signal (if (file-exists-p "scanner.cc") c++ cc) nil t nil - `("-fPIC" "-shared" - ,@(directory-files - default-directory nil - (rx bos (+ anychar) ".o" eos)) - "-o" ,lib-name)) + (if (eq system-type 'cygwin) + `("-shared" "-Wl,-dynamicbase" + ,@(directory-files + default-directory nil + (rx bos (+ anychar) ".o" eos)) + "-o" ,lib-name) + `("-fPIC" "-shared" + ,@(directory-files + default-directory nil + (rx bos (+ anychar) ".o" eos)) + "-o" ,lib-name))) ;; Copy out. (unless (file-exists-p out-dir) (make-directory out-dir t))