]> git.eshelyaron.com Git - emacs.git/commitdiff
Enable ASLR for dynamic libraries on Cygwin
authorKen Brown <kbrown@cornell.edu>
Sun, 26 Mar 2023 19:02:30 +0000 (15:02 -0400)
committerKen Brown <kbrown@cornell.edu>
Mon, 27 Mar 2023 22:00:14 +0000 (18:00 -0400)
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
lisp/treesit.el

index 7d9832f588f38d769146c870ddbd941660b1032b..3c57ca79b125f255361209bfe5dd8a176ba710f5 100644 (file)
@@ -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.
index 2b0eca7f5c28368e7549eee8805a722f9a134a2c..e3c7d569ea6c72e54b16f74341732cf9bb190dc1 100644 (file)
@@ -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))