emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 66b43944615: Enable ASLR for dynamic libraries on Cygwin


From: Ken Brown
Subject: master 66b43944615: Enable ASLR for dynamic libraries on Cygwin
Date: Mon, 27 Mar 2023 18:00:57 -0400 (EDT)

branch: master
commit 66b4394461589d0db8690b7971000f687bd3ad57
Author: Ken Brown <kbrown@cornell.edu>
Commit: Ken Brown <kbrown@cornell.edu>

    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.
---
 lisp/emacs-lisp/comp.el |  5 +++--
 lisp/treesit.el         | 16 +++++++++++-----
 2 files changed, 14 insertions(+), 7 deletions(-)

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))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]