| @@ -1,128 +1,128 @@ | | | @@ -1,128 +1,128 @@ |
1 | # $NetBSD: clang.mk,v 1.44 2024/03/20 10:47:22 schmonz Exp $ | | 1 | # $NetBSD: clang.mk,v 1.45 2024/03/27 11:33:00 schmonz Exp $ |
2 | # | | 2 | # |
3 | # This is the compiler definition for the clang compiler. | | 3 | # This is the compiler definition for the clang compiler. |
4 | # | | 4 | # |
5 | # User-settable variables: | | 5 | # User-settable variables: |
6 | # | | 6 | # |
7 | # CLANGBASE | | 7 | # CLANGBASE |
8 | # The base directory where the compiler is installed. | | 8 | # The base directory where the compiler is installed. |
9 | # | | 9 | # |
10 | | | 10 | |
11 | .if !defined(COMPILER_CLANG_MK) | | 11 | .if !defined(COMPILER_CLANG_MK) |
12 | COMPILER_CLANG_MK= defined | | 12 | COMPILER_CLANG_MK= defined |
13 | | | 13 | |
14 | # Add the dependency on clang | | 14 | # Add the dependency on clang |
15 | # TODO: may be installed already, check for this | | 15 | # TODO: may be installed already, check for this |
16 | #TOOL_DEPENDS+= clang-[0-9]*:../../lang/clang | | 16 | #TOOL_DEPENDS+= clang-[0-9]*:../../lang/clang |
17 | | | 17 | |
18 | .include "../../mk/bsd.prefs.mk" | | 18 | .include "../../mk/bsd.prefs.mk" |
19 | | | 19 | |
20 | CLANGBASE?= ${TOOLBASE} | | 20 | CLANGBASE?= ${TOOLBASE} |
21 | LANGUAGES.clang= # empty | | 21 | LANGUAGES.clang= # empty |
22 | | | 22 | |
23 | .if exists(${CLANGBASE}/bin/clang) | | 23 | .if exists(${CLANGBASE}/bin/clang) |
24 | LANGUAGES.clang+= c objc | | 24 | LANGUAGES.clang+= c objc |
25 | _COMPILER_STRIP_VARS+= CC | | 25 | _COMPILER_STRIP_VARS+= CC |
26 | CCPATH= ${CLANGBASE}/bin/clang | | 26 | CCPATH= ${CLANGBASE}/bin/clang |
27 | PKG_CC:= ${CCPATH} | | 27 | PKG_CC:= ${CCPATH} |
28 | .endif | | 28 | .endif |
29 | | | 29 | |
30 | .if exists(${CLANGBASE}/bin/clang++) | | 30 | .if exists(${CLANGBASE}/bin/clang++) |
31 | LANGUAGES.clang+= c++ | | 31 | LANGUAGES.clang+= c++ |
32 | _COMPILER_STRIP_VARS+= CXX | | 32 | _COMPILER_STRIP_VARS+= CXX |
33 | CXXPATH= ${CLANGBASE}/bin/clang++ | | 33 | CXXPATH= ${CLANGBASE}/bin/clang++ |
34 | PKG_CXX:= ${CXXPATH} | | 34 | PKG_CXX:= ${CXXPATH} |
35 | .endif | | 35 | .endif |
36 | | | 36 | |
37 | .if exists(${CLANGBASE}/bin/clang-cpp) | | 37 | .if exists(${CLANGBASE}/bin/clang-cpp) |
38 | CPPPATH= ${CLANGBASE}/bin/clang-cpp | | 38 | CPPPATH= ${CLANGBASE}/bin/clang-cpp |
39 | PKG_CPP:= ${CPPPATH} | | 39 | PKG_CPP:= ${CPPPATH} |
40 | .endif | | 40 | .endif |
41 | | | 41 | |
42 | .if !defined(CC_VERSION) | | 42 | .if !defined(CC_VERSION) |
43 | . if exists(${CCPATH}) | | 43 | . if exists(${CCPATH}) |
44 | CLANG_VERSION!= ${CCPATH} -dumpversion 2>&1 || ${ECHO} 0 | | 44 | CLANG_VERSION!= ${CCPATH} -dumpversion 2>&1 || ${ECHO} 0 |
45 | . else | | 45 | . else |
46 | CLANG_VERSION= 0 | | 46 | CLANG_VERSION= 0 |
47 | . endif | | 47 | . endif |
48 | CC_VERSION= clang-${CLANG_VERSION} | | 48 | CC_VERSION= clang-${CLANG_VERSION} |
49 | .endif | | 49 | .endif |
50 | | | 50 | |
51 | # | | 51 | # |
52 | # TODO: CC_VERSION_STRING is obsolete and should be removed at some point. | | 52 | # TODO: CC_VERSION_STRING is obsolete and should be removed at some point. |
53 | # | | 53 | # |
54 | CC_VERSION_STRING= ${CC_VERSION} | | 54 | CC_VERSION_STRING= ${CC_VERSION} |
55 | | | 55 | |
56 | _COMPILER_ABI_FLAG.32= -m32 | | 56 | _COMPILER_ABI_FLAG.32= -m32 |
57 | _COMPILER_ABI_FLAG.64= -m64 | | 57 | _COMPILER_ABI_FLAG.64= -m64 |
58 | | | 58 | |
59 | .include "gcc-style-args.mk" | | 59 | .include "gcc-style-args.mk" |
60 | | | 60 | |
61 | LDFLAGS+= ${_CLANG_LDFLAGS} | | 61 | LDFLAGS+= ${_CLANG_LDFLAGS} |
62 | | | 62 | |
63 | # _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the | | 63 | # _LANGUAGES.<compiler> is ${LANGUAGES.<compiler>} restricted to the |
64 | # ones requested by the package in USE_LANGUAGES. | | 64 | # ones requested by the package in USE_LANGUAGES. |
65 | # | | 65 | # |
66 | _LANGUAGES.clang= # empty | | 66 | _LANGUAGES.clang= # empty |
67 | .for _lang_ in ${USE_LANGUAGES} | | 67 | .for _lang_ in ${USE_LANGUAGES} |
68 | _LANGUAGES.clang+= ${LANGUAGES.clang:M${_lang_}} | | 68 | _LANGUAGES.clang+= ${LANGUAGES.clang:M${_lang_}} |
69 | .endfor | | 69 | .endfor |
70 | | | 70 | |
71 | PKGSRC_FORTRAN?=gfortran | | 71 | PKGSRC_FORTRAN?=gfortran |
72 | | | 72 | |
73 | .if !empty(PKGSRC_FORTRAN) && (!empty(USE_LANGUAGES:Mfortran) || !empty(USE_LANGUAGES:Mfortran77)) | | 73 | .if !empty(PKGSRC_FORTRAN) && (!empty(USE_LANGUAGES:Mfortran) || !empty(USE_LANGUAGES:Mfortran77)) |
74 | . include "../../mk/compiler/${PKGSRC_FORTRAN}.mk" | | 74 | . include "../../mk/compiler/${PKGSRC_FORTRAN}.mk" |
75 | .endif | | 75 | .endif |
76 | | | 76 | |
77 | _WRAP_EXTRA_ARGS.CC+= -Qunused-arguments | | 77 | _WRAP_EXTRA_ARGS.CC+= -Qunused-arguments |
78 | CWRAPPERS_APPEND.cc+= -Qunused-arguments | | 78 | CWRAPPERS_APPEND.cc+= -Qunused-arguments |
79 | CWRAPPERS_PREPEND.cc+= -Qunused-arguments | | 79 | CWRAPPERS_PREPEND.cc+= -Qunused-arguments |
80 | _WRAP_EXTRA_ARGS.CXX+= -Qunused-arguments | | 80 | _WRAP_EXTRA_ARGS.CXX+= -Qunused-arguments |
81 | CWRAPPERS_APPEND.cxx+= -Qunused-arguments | | 81 | CWRAPPERS_APPEND.cxx+= -Qunused-arguments |
82 | | | 82 | |
83 | .if defined(_PKGSRC_BARRIER) | | 83 | .if defined(_PKGSRC_BARRIER) |
84 | # Xcode 12 and upstream Clang 16 have a zealous new default that the | | 84 | # Xcode 12 (Apple clang-1200.0.32.2) and upstream Clang 16 have a |
85 | # wide world of random third-party software isn't ready for. Turn it | | 85 | # zealous new default that the wide world of random third-party software |
86 | # back off by default. | | 86 | # isn't ready for. Turn it back off by default. |
87 | # | | 87 | # |
88 | # Packages and users can override via CFLAGS/CPPFLAGS. | | 88 | # Packages and users can override via CFLAGS/CPPFLAGS. |
89 | _NOERROR_IMPLICIT_cmd= ${CCPATH} -\#\#\# -E -x c /dev/null \ | | 89 | _NOERROR_IMPLICIT_cmd= ${CCPATH} -\#\#\# -E -x c /dev/null \ |
90 | 2>&1 \ | | 90 | 2>&1 \ |
91 | | ${GREP} -q Werror=implicit-function-declaration \ | | 91 | | ${GREP} -q Werror=implicit-function-declaration \ |
92 | && ${ECHO} -Wno-error=implicit-function-declaration \ | | 92 | && ${ECHO} -Wno-error=implicit-function-declaration \ |
93 | || ${TRUE} | | 93 | || ${TRUE} |
94 | CWRAPPERS_PREPEND.cc+= ${_NOERROR_IMPLICIT_cmd:sh} | | 94 | CWRAPPERS_PREPEND.cc+= ${_NOERROR_IMPLICIT_cmd:sh} |
95 | | | 95 | |
96 | # Xcode 15 (Apple clang-1500.3.9.4) and upstream Clang 16 have several | | 96 | # Xcode 15 (Apple clang-1500.3.9.4) and upstream Clang 16 have several |
97 | # more zealous new defaults. We can't default them off as precisely | | 97 | # more zealous new defaults. We can't default them off as precisely |
98 | # (they don't show up in `clang -###` output), so we simply attempt to | | 98 | # (they don't show up in `clang -###` output), so we simply attempt to |
99 | # turn them off for any clang that doesn't complain when we try. | | 99 | # turn them off for any clang that doesn't complain when we try. |
100 | # | | 100 | # |
101 | # Packages and users can override via CFLAGS/CPPFLAGS. | | 101 | # Packages and users can override via CFLAGS/CPPFLAGS. |
102 | # | | 102 | # |
103 | # As soon as 2024Q1 branches, we should: | | 103 | # As soon as 2024Q1 branches, we should: |
104 | # | | 104 | # |
105 | # 1. Do a bulk build with all these -Wno-error tweaks removed, so we can | | 105 | # 1. Do a bulk build with all these -Wno-error tweaks removed, so we can |
106 | # see how much is broken. | | 106 | # see how much is broken. |
107 | # 2. If it's "too much" breakage and we'll have to keep overriding these | | 107 | # 2. If it's "too much" breakage and we'll have to keep overriding these |
108 | # compiler defaults for "a while", find a way to accomplish them with | | 108 | # compiler defaults for "a while", find a way to accomplish them with |
109 | # fewer compiler invocations. (Some ideas: define a default | | 109 | # fewer compiler invocations. (Some ideas: define a default |
110 | # FORCE_C_STD, or apply overrides keyed on CC_VERSION or similar.) Do | | 110 | # FORCE_C_STD, or apply overrides keyed on CC_VERSION or similar.) Do |
111 | # a bulk build to make sure things continue to work as before. | | 111 | # a bulk build to make sure things continue to work as before. |
112 | # 3. Otherwise, fix as much as we can before 2024Q2. This will help with | | 112 | # 3. Otherwise, fix as much as we can before 2024Q2. This will help with |
113 | # gcc 14 (which has many similar new defaults) as well. | | 113 | # gcc 14 (which has many similar new defaults) as well. |
114 | _WERROR_CLANG16= implicit-int int-conversion incompatible-pointer-types | | 114 | _WERROR_CLANG16= implicit-int int-conversion incompatible-pointer-types |
115 | _NOERROR_CLANG16_cmd= for _warn_ in ${_WERROR_CLANG16}; do \ | | 115 | _NOERROR_CLANG16_cmd= for _warn_ in ${_WERROR_CLANG16}; do \ |
116 | ${CCPATH} -\#\#\# -Wno-error=$${_warn_} -x c /dev/null \ | | 116 | ${CCPATH} -\#\#\# -Wno-error=$${_warn_} -x c /dev/null \ |
117 | >/dev/null 2>&1 \ | | 117 | >/dev/null 2>&1 \ |
118 | && ${ECHO} -Wno-error=$${_warn_} \ | | 118 | && ${ECHO} -Wno-error=$${_warn_} \ |
119 | || ${TRUE}; \ | | 119 | || ${TRUE}; \ |
120 | done | | 120 | done |
121 | CWRAPPERS_PREPEND.cc+= ${_NOERROR_CLANG16_cmd:sh} | | 121 | CWRAPPERS_PREPEND.cc+= ${_NOERROR_CLANG16_cmd:sh} |
122 | .endif | | 122 | .endif |
123 | | | 123 | |
124 | .for _version_ in ${_CXX_STD_VERSIONS} | | 124 | .for _version_ in ${_CXX_STD_VERSIONS} |
125 | _CXX_STD_FLAG.${_version_}?= -std=${_version_} | | 125 | _CXX_STD_FLAG.${_version_}?= -std=${_version_} |
126 | .endfor | | 126 | .endfor |
127 | | | 127 | |
128 | .endif # COMPILER_CLANG_MK | | 128 | .endif # COMPILER_CLANG_MK |