summaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
Diffstat (limited to 'lisp')
-rw-r--r--lisp/emacs-lisp/ert-x.el6
-rw-r--r--lisp/man.el2
-rw-r--r--lisp/subr.el57
3 files changed, 49 insertions, 16 deletions
diff --git a/lisp/emacs-lisp/ert-x.el b/lisp/emacs-lisp/ert-x.el
index 82cc772e09c..147787d3d38 100644
--- a/lisp/emacs-lisp/ert-x.el
+++ b/lisp/emacs-lisp/ert-x.el
@@ -526,11 +526,7 @@ The same keyword arguments are supported as in
(defun ert-gcc-is-clang-p ()
"Return non-nil if the `gcc' command actually runs the Clang compiler."
- ;; Some macOS machines run llvm when you type gcc. (!)
- ;; We can't even check if it's a symlink; it's a binary placed in
- ;; "/usr/bin/gcc". So we need to check the output.
- (string-match "Apple \\(LLVM\\|[Cc]lang\\)\\|Xcode\\.app"
- (shell-command-to-string "gcc --version")))
+ (internal--gcc-is-clang-p))
(defvar tramp-default-host-alist)
(defvar tramp-methods)
diff --git a/lisp/man.el b/lisp/man.el
index b030e57aaf8..103131fbb34 100644
--- a/lisp/man.el
+++ b/lisp/man.el
@@ -232,7 +232,7 @@ the associated section number."
(defcustom Man-header-file-path (internal--c-header-file-path)
"C Header file search path used in Man."
- :version "24.1" ; add multiarch
+ :version "31.1"
:type '(repeat string))
(defcustom Man-name-local-regexp (concat "^" (regexp-opt '("NOM" "NAME")) "$")
diff --git a/lisp/subr.el b/lisp/subr.el
index 9044a92c5f5..5be8d8f52d4 100644
--- a/lisp/subr.el
+++ b/lisp/subr.el
@@ -7556,6 +7556,17 @@ and return the value found in PLACE instead."
,(funcall setter val)
,val)))))
+(defun internal--gcc-is-clang-p ()
+ "Return non-nil if the `gcc' command actually runs the Clang compiler."
+ ;; Recent macOS machines run llvm when you type gcc by default. (!)
+ ;; We can't even check if it's a symlink; it's a binary placed in
+ ;; "/usr/bin/gcc". So we need to check the output.
+ (when-let* ((out (ignore-errors
+ (with-temp-buffer
+ (call-process "gcc" nil t nil "--version")
+ (buffer-string)))))
+ (string-match "Apple \\(LLVM\\|[Cc]lang\\)\\|Xcode\\.app" out)))
+
(defun internal--c-header-file-path ()
"Return search path for C header files (a list of strings)."
;; FIXME: It's not clear that this is a good place to put this, or
@@ -7563,15 +7574,41 @@ and return the value found in PLACE instead."
;; See also (Bug#10702):
;; cc-search-directories, semantic-c-dependency-system-include-path,
;; semantic-gcc-setup
- (let ((arch (with-temp-buffer
- (when (eq 0 (ignore-errors
- (call-process "gcc" nil '(t nil) nil
- "-print-multiarch")))
- (goto-char (point-min))
- (buffer-substring (point) (line-end-position)))))
- (base '("/usr/include" "/usr/local/include")))
- (if (zerop (length arch))
- base
- (append base (list (expand-file-name arch "/usr/include"))))))
+ (delete-dups
+ (let ((base '("/usr/include" "/usr/local/include")))
+ (cond ((or (internal--gcc-is-clang-p)
+ (and (executable-find "clang")
+ (not (executable-find "gcc"))))
+ ;; This is either macOS, or a system with clang only.
+ (with-temp-buffer
+ (ignore-errors
+ (call-process (if (internal--gcc-is-clang-p) "gcc" "clang")
+ nil t nil
+ "-v" "-E" "-"))
+ (goto-char (point-min))
+ (narrow-to-region
+ (save-excursion
+ (re-search-forward
+ "^#include <\\.\\.\\.> search starts here:\n" nil t)
+ (point))
+ (save-excursion
+ (re-search-forward "^End of search list.$" nil t)
+ (pos-bol)))
+ (while (search-forward "(framework directory)" nil t)
+ (delete-line))
+ (append base
+ (reverse
+ (split-string (buffer-substring-no-properties
+ (point-min) (point-max)))))))
+ ;; Prefer GCC.
+ ((let ((arch (with-temp-buffer
+ (when (eq 0 (ignore-errors
+ (call-process "gcc" nil '(t nil) nil
+ "-print-multiarch")))
+ (goto-char (point-min))
+ (buffer-substring (point) (line-end-position))))))
+ (if (zerop (length arch))
+ base
+ (append base (list (expand-file-name arch "/usr/include"))))))))))
;;; subr.el ends here