Skip to content

Commit

Permalink
configure: Fall back to clang
Browse files Browse the repository at this point in the history
Clang is a compiler that is highly compatible with GCC. When GCC is
unavailable, try looking for Clang.
  • Loading branch information
magicant committed Dec 2, 2023
1 parent 70469df commit 8ed979d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 13 deletions.
12 changes: 6 additions & 6 deletions README.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ share/initialization/sample) ファイルを参考に自分用の `~/.yashrc`
* C 言語では、ナル文字は文字列の終わりを表します。そのため、入力した
ファイルの内容や文字列にナル文字が含まれているとそれ以降の部分が正
しく処理されなくなってしまいます。
* ソース内の随所で GCC の拡張機能である `__attribute__` キーワードを使
用しています。GCC 以外の環境ではプリプロセッサによって消去するよう
にしていますが`__attribute__` 識別子を他の用途で使用している処理系
ではコンパイルに支障をきたすかもしれません。他にもいくつか '_' で始
まる識別子を使用しているため、非常に特殊な環境では正しくコンパイル
できないかもしれません
* ソース内の随所で GCC の拡張機能である `__attribute__` キーワードを
使用しています。GCC および Clang 以外の環境ではプリプロセッサによっ
て消去するようにしていますが`__attribute__` 識別子を他の用途で使
用している処理系ではコンパイルに支障をきたすかもしれません。他にも
いくつか '_' で始まる識別子を使用しているため、非常に特殊な環境では
正しくコンパイルできないかもしれません
* いくつかのシグナルは特定の番号を持っていると仮定しています:
SIGHUP=1 SIGINT=2 SIGQUIT=3 SIGABRT=6
SIGKILL=9 SIGALRM=14 SIGTERM=15
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,11 +95,11 @@ system.
the shell itself contains a null character, characters following
the null character will be ignored.
* The GCC extension keyword `__attribute__` is used in the source
code. When not compiled with GCC, this keyword is removed by the
preprocessor, so generally there is no harm. But if your compiler
uses this keyword for any other purpose, compilation may fail.
Additionally, some other identifiers starting with `_` may cause
compilation errors on some rare environments.
code. When not compiled with GCC or Clang, this keyword is removed
by the preprocessor, so generally there is no harm. But if your
compiler uses this keyword for any other purpose, compilation may
fail. Additionally, some other identifiers starting with `_` may
cause compilation errors on some rare environments.
* Some signals are assumed to have the specific numbers:
SIGHUP=1 SIGINT=2 SIGQUIT=3 SIGABRT=6
SIGKILL=9 SIGALRM=14 SIGTERM=15
Expand Down
11 changes: 9 additions & 2 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ Usage: sh $0 [options...]
Available options:
--no-create do not create output files
--debug configure for debug build (GCC required)
--debug configure for debug build (GCC or Clang required)
Installation options:
--prefix=PREFIX install architecture-independent files in PREFIX
Expand Down Expand Up @@ -395,7 +395,6 @@ esac
# define options for debugging
if ${debug}
then
cc="${CC-gcc}"
cflags="${CFLAGS--pedantic -MMD -Wall -Wextra -O1 -fno-inline -ggdb}"
else
defconfigh "NDEBUG"
Expand All @@ -419,6 +418,14 @@ elif
then
checked "yes (using gcc)"
cc='gcc'
elif
[ x"${cc}" = x"c99" ] && [ x"${CC+set}" != x"set" ] && (
cc='clang'
trymake && tryexec
)
then
checked "yes (using clang)"
cc='clang'
else
checked "no"
printf 'Compiler "%s" not found or not working.\n' "${CC-${cc}}" >&2
Expand Down

0 comments on commit 8ed979d

Please sign in to comment.