Skip to content

Commit d975bd2

Browse files
author
Commitfest Bot
committed
[CF 5885] v2 - Decouple C++ support in Meson's PGXS from LLVM enablement
This branch was automatically generated by a robot using patches from an email thread registered at: https://commitfest.postgresql.org/patch/5885 The branch will be overwritten each time a new patch version is posted to the thread, and also periodically to check for bitrot caused by changes on the master branch. Patch(es): https://www.postgresql.org/message-id/[email protected] Author(s): Tristan Partin
2 parents 93b7ab5 + f57f3eb commit d975bd2

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

meson.build

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ build_system = build_machine.system()
4141
host_cpu = host_machine.cpu_family()
4242

4343
cc = meson.get_compiler('c')
44+
have_cpp = add_languages('cpp', required: false, native: false)
45+
if have_cpp
46+
cpp = meson.get_compiler('cpp')
47+
endif
4448

4549
not_found_dep = dependency('', required: false)
4650
thread_dep = dependency('threads')
@@ -827,15 +831,13 @@ endif
827831

828832
llvmopt = get_option('llvm')
829833
llvm = not_found_dep
830-
if add_languages('cpp', required: llvmopt, native: false)
834+
if have_cpp and not llvmopt.disabled()
831835
llvm = dependency('llvm', version: '>=14', method: 'config-tool', required: llvmopt)
832836

833837
if llvm.found()
834838

835839
cdata.set('USE_LLVM', 1)
836840

837-
cpp = meson.get_compiler('cpp')
838-
839841
llvm_binpath = llvm.get_variable(configtool: 'bindir')
840842

841843
ccache = find_program('ccache', native: true, required: false)
@@ -844,8 +846,13 @@ if add_languages('cpp', required: llvmopt, native: false)
844846
# find via PATH, too.
845847
clang = find_program(llvm_binpath / 'clang', 'clang', required: true)
846848
endif
847-
elif llvmopt.auto()
848-
message('llvm requires a C++ compiler')
849+
else
850+
msg = 'llvm requires a C++ compiler'
851+
if llvmopt.auto()
852+
message(msg)
853+
elif llvmopt.enabled()
854+
error(msg)
855+
endif
849856
endif
850857

851858

@@ -2061,7 +2068,7 @@ common_functional_flags = [
20612068
]
20622069

20632070
cflags += cc.get_supported_arguments(common_functional_flags)
2064-
if llvm.found()
2071+
if have_cpp
20652072
cxxflags += cpp.get_supported_arguments(common_functional_flags)
20662073
endif
20672074

@@ -2085,7 +2092,7 @@ common_warning_flags = [
20852092
]
20862093

20872094
cflags_warn += cc.get_supported_arguments(common_warning_flags)
2088-
if llvm.found()
2095+
if have_cpp
20892096
cxxflags_warn += cpp.get_supported_arguments(common_warning_flags)
20902097
endif
20912098

@@ -2139,7 +2146,7 @@ foreach w : negative_warning_flags
21392146
if cc.has_argument('-W' + w)
21402147
cflags_warn += '-Wno-' + w
21412148
endif
2142-
if llvm.found() and cpp.has_argument('-W' + w)
2149+
if have_cpp and cpp.has_argument('-W' + w)
21432150
cxxflags_warn += '-Wno-' + w
21442151
endif
21452152
endforeach
@@ -2200,7 +2207,7 @@ elif optimization == 's'
22002207
endif
22012208

22022209
cflags_builtin = cc.get_supported_arguments(common_builtin_flags)
2203-
if llvm.found()
2210+
if have_cpp
22042211
cxxflags_builtin = cpp.get_supported_arguments(common_builtin_flags)
22052212
endif
22062213

@@ -3929,7 +3936,7 @@ summary(
39293936
section: 'Compiler Flags',
39303937
)
39313938

3932-
if llvm.found()
3939+
if have_cpp
39333940
summary(
39343941
{
39353942
'C++ compiler': '@0@ @1@'.format(cpp.get_id(), cpp.version()),

src/include/meson.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ config_paths_data.set_quoted('MANDIR', dir_prefix / dir_man)
3636
var_cc = ' '.join(cc.cmd_array())
3737
var_cpp = ' '.join(cc.cmd_array() + ['-E'])
3838
var_cflags = ' '.join(cflags + cflags_builtin + cflags_warn + get_option('c_args'))
39-
if llvm.found()
39+
if have_cpp
4040
var_cxxflags = ' '.join(cxxflags + cxxflags_builtin + cxxflags_warn + get_option('cpp_args'))
4141
else
4242
var_cxxflags = ''

src/makefiles/meson.build

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ if not working_strip
3131
strip_shared_cmd = [':']
3232
endif
3333

34-
3534
pgxs_kv = {
3635
'PACKAGE_URL': pg_url,
3736
'PACKAGE_VERSION': pg_version,
@@ -119,16 +118,20 @@ pgxs_kv = {
119118
'LIBS': var_libs,
120119
}
121120

121+
if have_cpp
122+
pgxs_kv += {
123+
'CXX': ' '.join(cpp.cmd_array()),
124+
}
125+
endif
126+
122127
if llvm.found()
123128
pgxs_kv += {
124129
'CLANG': clang.full_path(),
125-
'CXX': ' '.join(cpp.cmd_array()),
126130
'LLVM_BINPATH': llvm_binpath,
127131
}
128132
else
129133
pgxs_kv += {
130134
'CLANG': '',
131-
'CXX': '',
132135
'LLVM_BINPATH': '',
133136
}
134137
endif

0 commit comments

Comments
 (0)