/
conanfile.py
612 lines (549 loc) · 24.8 KB
/
conanfile.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
import os, shutil, glob
from conans import ConanFile, CMake, tools, RunEnvironment
from conans.errors import ConanInvalidConfiguration
from conans.tools import Version
llvm_projects = [
'all',
'clang',
'clang-tools-extra',
'compiler-rt',
'debuginfo-tests',
'libc',
'libclc',
'libcxx',
'libcxxabi',
'libunwind',
'lld',
'lldb',
'mlir',
'openmp',
'parallel-libs',
'polly',
'pstl'
]
default_llvm_projects = [
'clang',
'clang-tools-extra',
'compiler-rt',
'libcxx',
'libcxxabi',
'libunwind',
'lld',
'lldb'
]
llvm_targets = [
'all',
'AArch64',
'AMDGPU',
'ARM',
'BPF',
'Hexagon',
'Lanai',
'Mips',
'MSP430',
'NVPTX',
'RISCV',
'SystemZ',
'WebAssembly',
'X86',
'XCore'
]
default_llvm_targets = [
'X86'
]
llvm_libs = [
'LLVMCore',
'LLVMAnalysis',
'LLVMSupport',
'LLVMipo',
'LLVMIRReader',
'LLVMBinaryFormat',
'LLVMBitReader',
'LLVMBitWriter',
'LLVMMC',
'LLVMMCParser',
'LLVMTransformUtils',
'LLVMScalarOpts',
'LLVMLTO',
'LLVMCoroutines',
'LLVMCoverage',
'LLVMInstCombine',
'LLVMInstrumentation',
'LLVMLinker',
'LLVMObjCARCOpts',
'LLVMObject',
'LLVMPasses',
'LLVMProfileData',
'LLVMTarget',
'LLVMLibDriver',
'LLVMLineEditor',
'LLVMMIRParser',
'LLVMOption',
'LLVMRuntimeDyld',
'LLVMSelectionDAG',
'LLVMSymbolize',
'LLVMTableGen',
'LLVMVectorize',
'clangToolingRefactoring',
'clangStaticAnalyzerCore',
'clangDynamicASTMatchers',
'clangCodeGen',
'clangFrontendTool',
'clang',
'clangEdit',
'clangRewriteFrontend',
'clangDriver',
'clangSema',
'clangASTMatchers',
'clangSerialization',
'clangBasic',
'clangAST',
'clangTooling',
'clangStaticAnalyzerFrontend',
'clangFormat',
'clangLex',
'clangFrontend',
'clangRewrite',
'clangToolingCore',
'clangIndex',
'clangAnalysis',
'clangParse',
'clangStaticAnalyzerCheckers',
'clangARCMigrate',
]
# If your project does not depend on LLVM libs (LibTooling, etc.),
# than you can clear default_llvm_libs (just disable in options all libs)
default_llvm_libs = llvm_libs
# Sanitizer is well supported on Linux
# see https://clang.llvm.org/docs/MemorySanitizer.html#handling-external-code
llvm_sanitizers = [
'msan',
'tsan',
'ubsan',
'asan'
]
# sanitizers disabled by default
default_llvm_sanitizers = []
# Users locally they get the 1.0.0 version,
# without defining any env-var at all,
# and CI servers will append the build number.
# USAGE
# version = get_version("1.0.0")
# BUILD_NUMBER=-pre1+build2 conan export-pkg . my_channel/release
def get_version(name, version):
envvar = os.getenv("{}_BUILD_NUMBER".format(name))
return (version + envvar) if envvar else version
def get_name(default):
envvar = os.getenv("LLVM_INSTALLER_PACKAGE_NAME", default)
return envvar
# see https://github.com/conan-io/conan-center-index/blob/master/recipes/protobuf/3.9.x/conanfile.py
class Clang9InstallerConan(ConanFile):
name = get_name("llvm_9_installer")
version = get_version(name, "master")
description = "Conan installer for clang 9, llvm 9, iwyu, sanitizers, etc."
topics = ("conan", "clang", "llvm", "iwyu", "include-what-you-use", "libc++", "libcpp")
url = "https://github.com/blockspacer/llvm_9_installer"
homepage = "https://github.com/blockspacer/llvm_9_installer"
repo_url = 'https://github.com/blockspacer/llvm_9_installer.git'
license = "MIT"
exports_sources = ["LICENSE.md"]
generators = 'cmake_find_package', "cmake", "cmake_paths"
# always - The package will be built always,
# retrieving each time the source code executing the source method.
# The always policy will retrieve the sources
# each time the package is installed,
# so it can be useful for providing a “latest” mechanism
# or ignoring the uploaded binary packages.
build_policy = "always"
short_paths = True
settings = "os_build", "build_type", "arch_build", "compiler", "arch"
# Allows to enforce default options for `llvm_xxx` dependency
# and check that wrapper package (`llvm_xxx_installer`) uses same set of options
# as `llvm_xxx` dependency (because different sets of options must not collide).
# 'ANY' means use same default value as in `llvm_xxx` dependency
#
# For example, if you set `llvm_xxx_installer:include_what_you_use=False`,
# than `llvm_xxx:include_what_you_use=False` will be set automatically
llvm_options = {
**{
'with_' + library : library in default_llvm_libs for library in llvm_libs },
**{
'with_' + project : project in default_llvm_projects for project in llvm_projects },
**{
'with_' + target : target in default_llvm_targets for target in llvm_targets },
**{
'use_sanitizer': 'None',
'lto': 'ANY', # no default value
'exceptions': 'ANY', # no default value
'threads': 'ANY', # no default value
'unwind_tables': 'ANY', # no default value
'fPIC': 'ANY', # no default value
'shared': 'ANY', # no default value
'rtti': 'ANY', # no default value
'libffi': 'ANY', # no default value
'libz': 'ANY', # no default value
"include_what_you_use": 'ANY', # no default value
"add_to_builddirs": 'ANY', # no default value
"add_to_libdirs": 'ANY', # no default value
"add_to_bindirs": 'ANY', # no default value
"add_to_system_libs": 'ANY', # no default value
"add_to_includedirs": 'ANY', # no default value
# If `True` than will add 'LLVMCore', 'LLVMAnalysis', 'LLVMSupport',
# 'clangAST', 'clangTooling', etc. into `self.cpp_info.libs`
"link_with_llvm_libs": False
}}
options = {
**dict([(key, 'ANY') for (key, value) in llvm_options.items()]),
**{
# Will set `-stdlib=libc++` if `True`
'link_libcxx': [True, False],
# Will set `self.env_info.CXX` if `True`
'compile_with_clang': [True, False],
'LLVM_PKG_NAME': 'ANY',
'LLVM_PKG_VER': 'ANY',
'LLVM_PKG_CHANNEL': 'ANY',
'LLVM_CONAN_CLANG_VER': 'ANY',
}}
default_options = {
**dict([(key, value) for (key, value) in llvm_options.items()]),
**{
'link_libcxx': True,
'compile_with_clang': True,
'LLVM_PKG_NAME': "llvm_9",
'LLVM_PKG_VER': "master",
'LLVM_PKG_CHANNEL': "conan/stable",
'LLVM_CONAN_CLANG_VER': '9.0.1',
}}
# Same as
# self.options["llvm_xxx"].include_what_you_use = self.options.include_what_you_use
# etc.
def set_dependency_options(self, dependency_name, dependency_options_dict):
options_dict = dict([(key, value) for key, value in self.options.items()])
for key in dependency_options_dict.keys():
if (not key in options_dict.keys()):
raise ConanInvalidConfiguration(str(key) + " must be in options")
# 'ANY' - no default value
if getattr(self.options, key) != 'ANY':
setattr(self.options[dependency_name], key, getattr(self.options, key))
# during package step we can check populated dependency options
# and validate that we did not forget about some dependency option
def check_options_same(self, dependency_name, dependency_options_dict):
for key, value in self.options[dependency_name].items():
# 'ANY' - no default value
if (getattr(self.options, key) != 'ANY' \
and not key in dependency_options_dict.keys()):
raise ConanInvalidConfiguration(str(key) + " must be in llvm_options")
# config_options() is used to configure or constraint the available options
# in a package, before they are given a value
def config_options(self):
self.set_dependency_options(str(self.options.LLVM_PKG_NAME), self.llvm_options)
# NOTE: do not use self.settings.compiler.sanitizer
# because it may throw ConanException if 'settings.compiler.sanitizer'
# doesn't exist in ~/.conan/settings.yml file.
@property
def _sanitizer(self):
# will return None if that setting or subsetting doesn’t exist
# and there is no default value assigned.
return str(self.settings.get_safe("compiler.sanitizer"))
# NOTE: we can not rely only on "compiler.sanitizer"
# because of separate options
@property
def _has_sanitizer_option(self):
return self.options.use_sanitizer != 'None'
def configure(self):
self.set_dependency_options(str(self.options.LLVM_PKG_NAME), self.llvm_options)
if self._sanitizer != 'None' \
and not self._has_sanitizer_option:
raise ConanInvalidConfiguration("sanitizers require options.use_sanitizer!=None")
if self._sanitizer != 'None' \
and not self.options.link_libcxx:
raise ConanInvalidConfiguration("sanitizers require compiler.libcxx=libc++")
if self._sanitizer != 'None' \
and not self.options.compile_with_clang:
raise ConanInvalidConfiguration("sanitizers require clang compiler")
self.output.info("compiler is {}".format(str(self.settings.compiler)))
if (self._sanitizer != 'None' or self._has_sanitizer_option) \
and not "clang" in str(self.settings.compiler):
raise ConanInvalidConfiguration("sanitizer requires clang")
#def build_requirements(self):
# self.output.info("build requirements")
#
# self.build_requires("{}/{}@{}".format( \
# self.options.LLVM_PKG_NAME, \
# self.options.LLVM_PKG_VER, \
# self.options.LLVM_PKG_CHANNEL))
def requirements(self):
self.output.info("requirements")
self.requires("{}/{}@{}".format( \
self.options.LLVM_PKG_NAME, \
self.options.LLVM_PKG_VER, \
self.options.LLVM_PKG_CHANNEL))
def package(self):
self.output.info("package")
self.check_options_same(str(self.options.LLVM_PKG_NAME), self.llvm_options)
self.copy(pattern="LICENSE", dst="licenses", src=self.build_folder)
# NOTE: It is build-time tool.
# Any project configuration must be able to depend on it.
def package_id(self):
self.output.info("package_id")
self.info.include_build_settings()
if self.settings.os_build == "Windows":
del self.info.settings.arch_build # same build is used for x86 and x86_64
del self.info.settings.arch
del self.info.settings.compiler
del self.info.settings.build_type
def prepend_to(self, var, value):
return value + " " + str(var)
def package_info(self):
self.output.info("package_info")
cxxflags = []
cflags = []
ldflags = []
common_build_flags = []
common_link_flags = []
# llvm_core clang_core llvm_tools
self.cpp_info.components["libcxx"].names["cmake_find_package"] = "libcxx"
self.cpp_info.components["libcxx"].names["cmake_find_package_multi"] = "libcxx"
self.cpp_info.components["libcxx"].requires = [\
"{}::{}".format(self.options.LLVM_PKG_NAME, self.options.LLVM_PKG_NAME)]
if self.options[str(self.options.LLVM_PKG_NAME)].add_to_includedirs:
self.cpp_info.components["libcxx"].requires.extend([\
"{}::includedirs".format(self.options.LLVM_PKG_NAME)])
if self.options[str(self.options.LLVM_PKG_NAME)].add_to_libdirs:
self.cpp_info.components["libcxx"].requires.extend([\
"{}::libdirs".format(self.options.LLVM_PKG_NAME)])
self.cpp_info.components["libclang_rt"].names["cmake_find_package"] = "libclang_rt"
self.cpp_info.components["libclang_rt"].names["cmake_find_package_multi"] = "libclang_rt"
self.cpp_info.components["libclang_rt"].requires = [\
"{}::{}".format(self.options.LLVM_PKG_NAME, self.options.LLVM_PKG_NAME)]
if self.options[str(self.options.LLVM_PKG_NAME)].link_with_llvm_libs:
self.cpp_info.components["libclang_rt"].requires.extend(\
["{}::clang_core".format(self.options.LLVM_PKG_NAME), \
"{}::llvm_core".format(self.options.LLVM_PKG_NAME)])
self.cpp_info.components["clang_compiler"].names["cmake_find_package"] = "clang_compiler"
self.cpp_info.components["clang_compiler"].names["cmake_find_package_multi"] = "llvm_tools"
self.cpp_info.components["clang_compiler"].requires = [\
"{}::{}".format(self.options.LLVM_PKG_NAME, self.options.LLVM_PKG_NAME)]
if self.options[str(self.options.LLVM_PKG_NAME)].add_to_bindirs:
self.cpp_info.components["clang_compiler"].requires.extend(\
["{}::llvm_tools".format(self.options.LLVM_PKG_NAME), \
"{}::bindirs".format(self.options.LLVM_PKG_NAME)])
llvm_root = self.deps_cpp_info[str(self.options.LLVM_PKG_NAME)].rootpath
self.env_info.LLVM_NORMPATH = os.path.normpath(llvm_root)
self.output.info("llvm rootpath: {}".format(llvm_root))
#
self.env_info.IWYU_PATH = os.path.join(llvm_root, "bin", "include-what-you-use")
self.env_info.CLANG_FORMAT_PATH = os.path.join(llvm_root, "bin", "clang-format")
self.env_info.SCAN_BUILD_PATH = os.path.join(llvm_root, "bin", "scan-build")
self.env_info.CLANG_TIDY_PATH = os.path.join(llvm_root, "bin", "clang-tidy")
self.env_info.CPP_ANALYZER_PATH = os.path.join(llvm_root, "libexec", "c++-analyzer")
self.env_info.CCC_ANALYZER_PATH = os.path.join(llvm_root, "libexec", "ccc-analyzer")
if self.options.link_libcxx:
for path in self.deps_cpp_info.res_paths:
self.cpp_info.components["libcxx"].resdirs.append(path)
if self.options.link_libcxx:
self.cpp_info.components["libcxx"].includedirs.append(llvm_root)
self.cpp_info.components["libcxx"].includedirs.append(os.path.join(llvm_root, "include"))
for path in self.deps_cpp_info.include_paths:
self.cpp_info.components["libcxx"].includedirs.append(path)
if self.options.link_libcxx:
self.env_info.LD_LIBRARY_PATH.append(os.path.join(llvm_root, "lib"))
for path in self.deps_cpp_info.lib_paths:
self.env_info.LD_LIBRARY_PATH.append(path)
self.env_info.PATH.append(os.path.join(llvm_root, "bin"))
self.env_info.PATH.append(os.path.join(llvm_root, "libexec"))
for path in self.deps_cpp_info.bin_paths:
self.env_info.PATH.append(path)
#
if self.options.compile_with_clang:
# see https://docs.conan.io/en/latest/systems_cross_building/cross_building.html
# and https://www.gnu.org/software/make/manual/html_node/Implicit-Variables.html
CXX = os.path.join(llvm_root, "bin", "clang++")
if not os.path.exists(CXX):
raise Exception("Unable to find path: {}".format(CXX))
self.env_info.CXX = CXX
CC = os.path.join(llvm_root, "bin", "clang")
if not os.path.exists(CC):
raise Exception("Unable to find path: {}".format(CC))
self.env_info.CC = CC
# TODO: use llvm-ar or llvm-lib?
# AR = os.path.join(llvm_root, "bin", "llvm-ar")
# if not os.path.exists(AR):
# raise Exception("Unable to find path: {}".format(AR))
# self.env_info.AR = AR
#
#STRIP = os.path.join(llvm_root, "bin", "llvm-strip")
#if not os.path.exists(STRIP):
# raise Exception("Unable to find path: {}".format(STRIP))
#self.env_info.STRIP = STRIP
#
# # TODO: use lld-link or ld.lld?
# # NOTE: llvm-ld replaced by llvm-ld
# LD = os.path.join(llvm_root, "bin", "ld.lld")
# if not os.path.exists(LD):
# raise Exception("Unable to find path: {}".format(LD))
# self.env_info.LD = LD
#
#NM = os.path.join(llvm_root, "bin", "llvm-nm")
#if not os.path.exists(NM):
# raise Exception("Unable to find path: {}".format(NM))
#self.env_info.NM = NM
#
# TODO:
# ADDR2LINE
#
# TODO:
# ELFEDIT
#
LLVM_CONFIG_PATH = os.path.join(llvm_root, "bin", "llvm-config")
if not os.path.exists(LLVM_CONFIG_PATH):
raise Exception("Unable to find path: {}".format(LLVM_CONFIG_PATH))
self.env_info.LLVM_CONFIG_PATH = LLVM_CONFIG_PATH
#
# # TODO: propagate to CMAKE_OBJDUMP?
# OBJDUMP = os.path.join(llvm_root, "bin", "llvm-objdump")
# if not os.path.exists(OBJDUMP):
# raise Exception("Unable to find path: {}".format(OBJDUMP))
# self.env_info.OBJDUMP = OBJDUMP
SYMBOLIZER = os.path.join(llvm_root, "bin", "llvm-symbolizer")
if not os.path.exists(SYMBOLIZER):
raise Exception("Unable to find path: {}".format(SYMBOLIZER))
self.env_info.SYMBOLIZER = SYMBOLIZER
#RANLIB = os.path.join(llvm_root, "bin", "llvm-ranlib")
#if not os.path.exists(RANLIB):
# raise Exception("Unable to find path: {}".format(RANLIB))
#self.env_info.RANLIB = RANLIB
# TODO: use llvm-as or clang?
#AS = os.path.join(llvm_root, "bin", "llvm-as")
#if not os.path.exists(STRIP):
# raise Exception("Unable to find path: {}".format(AS))
#self.env_info.AS = AS
# TODO: use llvm-rc-rc or llvm-rc
#RC = os.path.join(llvm_root, "bin", "llvm-rc")
#if not os.path.exists(RC):
# raise Exception("Unable to find path: {}".format(RC))
#self.env_info.RC = RC
# Preaload libs or add to
# LD_PRELOAD=.../lib/clang/9.0.1/lib/x86_64-unknown-linux-gnu/libclang_rt.asan.so
if (self._sanitizer != 'None' or self._has_sanitizer_option):
llvm_v = self.options.LLVM_CONAN_CLANG_VER
clang_libdir = os.path.join(llvm_root, "lib/clang/{}/lib".format(llvm_v))
if not os.path.exists(clang_libdir):
raise Exception("Unable to find path: {}".format(clang_libdir))
clang_libpaths = [os.path.join(clang_libdir, f) for f in os.listdir(clang_libdir)]
self.output.info("clang_libpaths = {}".format(str(clang_libpaths)))
# loop over
# lib/clang/9.0.1/lib/linux,
# lib/clang/9.0.1/lib/x86_64-unknown-linux-gnu,
# etc.
for path in clang_libpaths:
self.cpp_info.components["libclang_rt"].libdirs.extend([path])
libclang_rt_build_flags = []
libclang_rt_build_flags.append("-L{}".format(path))
libclang_rt_build_flags.append("-Wl,-rpath,{}".format(path))
libclang_rt_link_flags = []
libclang_rt_link_flags.append("-L{}".format(path))
libclang_rt_link_flags.append("-Wl,-rpath,{}".format(path))
self.cpp_info.components["libclang_rt"].cxxflags.extend(libclang_rt_build_flags)
self.cpp_info.components["libclang_rt"].cxxflags.extend(libclang_rt_build_flags)
self.cpp_info.components["libclang_rt"].cflags.extend(libclang_rt_build_flags)
self.cpp_info.components["libclang_rt"].cflags.extend(libclang_rt_build_flags)
self.cpp_info.components["libclang_rt"].sharedlinkflags.extend(libclang_rt_link_flags)
self.cpp_info.components["libclang_rt"].exelinkflags.extend(libclang_rt_link_flags)
self.cpp_info.components["libclang_rt"].sharedlinkflags.extend(libclang_rt_link_flags)
self.cpp_info.components["libclang_rt"].exelinkflags.extend(libclang_rt_link_flags)
# self.cpp_info.libdirs.extend(["{}/lib".format(path)])
for sanlib in ['libclang_rt.lsan.so', 'libclang_rt.asan.so', \
'libclang_rt.tsan.so', 'libclang_rt.msan.so', \
'libclang_rt.ubsan.so']:
if os.path.exists("{}/{}".format(path, sanlib)):
self.env_info.LD_PRELOAD.append("{}/{}".format(path, sanlib))
#
# if not os.path.exists(clang_libdir):
# raise ConanInvalidConfiguration(str(clang_libdir) + " must exist")
# clang_libpaths = []
# clang_libpaths.append("-lc++")
# self.env_info.LD_LIBRARY_PATH.extend(clang_libpaths)
if self.options.link_libcxx:
libcxx_link_flags = []
libcxx_link_flags.append("-lc++")
libcxx_link_flags.append("-lc++abi")
libcxx_link_flags.append("-lunwind")
libcxx_link_flags.append("-Wl,-rpath,{}/lib".format(llvm_root))
libcxx_link_flags.append("-stdlib=libc++")
self.cpp_info.components["libcxx"].sharedlinkflags.extend(libcxx_link_flags)
self.cpp_info.components["libcxx"].exelinkflags.extend(libcxx_link_flags)
#if self.options.link_libcxx:
# # we use libstdc++, not libstdc++
# badflag = '-stdlib=libstdc++'
# while badflag in self.env_info.LDFLAGS:
# self.env_info.LDFLAGS.remove(badflag)
# while badflag in self.env_info.CXXFLAGS:
# self.env_info.CXXFLAGS.remove(badflag)
# while badflag in self.env_info.CFLAGS:
# self.env_info.CFLAGS.remove(badflag)
# TODO: do we need '-static-libstdc++' support at all?
# if self.options.link_libcxx:
# badflag = '-static-libstdc++'
# while badflag in self.env_info.LDFLAGS:
# self.env_info.LDFLAGS.remove(badflag)
# while badflag in self.env_info.CXXFLAGS:
# self.env_info.CXXFLAGS.remove(badflag)
# while badflag in self.env_info.CFLAGS:
# self.env_info.CFLAGS.remove(badflag)
if (len(self._sanitizer) and self._sanitizer != 'None') \
or (len(str(self.options.use_sanitizer)) and self.options.use_sanitizer != "None"):
llvm_symbolizer = "\"{}/bin/llvm-symbolizer\"".format(llvm_root)
if not os.path.exists(llvm_symbolizer):
raise Exception("Unable to find path: {}".format(llvm_symbolizer))
self.env_info.UBSAN_SYMBOLIZER_PATH = llvm_symbolizer
self.env_info.ASAN_SYMBOLIZER_PATH = llvm_symbolizer
self.env_info.TSAN_SYMBOLIZER_PATH = llvm_symbolizer
self.env_info.MSAN_SYMBOLIZER_PATH = llvm_symbolizer
if self.options.link_libcxx:
# #cxxflags.append("-resource-dir {}/lib/clang/9.0.1".format(llvm_root))
# #self.cpp_info.libdirs.extend(["{}/lib".format(llvm_root)])
self.cpp_info.components["libcxx"].libdirs.extend(["{}/lib".format(llvm_root)])
libcxx_link_flags = []
libcxx_link_flags.append("-stdlib=libc++")
self.cpp_info.components["libcxx"].sharedlinkflags.extend(libcxx_link_flags)
self.cpp_info.components["libcxx"].exelinkflags.extend(libcxx_link_flags)
libcxx_build_flags = []
libcxx_build_flags.append("-Wno-unused-command-line-argument")
libcxx_build_flags.append("-Wno-error=unused-command-line-argument")
libcxx_build_flags.append("-nostdinc++")
libcxx_build_flags.append("-nodefaultlibs")
libcxx_build_flags.append("-lc++abi")
libcxx_build_flags.append("-lunwind")
libcxx_build_flags.append("-lc++")
libcxx_build_flags.append("-lm")
libcxx_build_flags.append("-lc")
libcxx_build_flags.append("-stdlib=libc++")
libcxx_build_flags.append("-isystem{}/include/c++/v1".format(llvm_root))
libcxx_build_flags.append("-isystem\"{}/include\"".format(llvm_root))
llvm_v = self.options.LLVM_CONAN_CLANG_VER
clang_incdir = os.path.join(llvm_root, "lib/clang/{}/include".format(llvm_v))
if not os.path.exists(clang_incdir):
raise Exception("Unable to find path: {}".format(clang_incdir))
libcxx_build_flags.append("-isystem{}".format(clang_incdir))
libcxx_build_flags.append("-L{}/lib".format(llvm_root))
libcxx_build_flags.append("-Wl,-rpath,{}/lib".format(llvm_root))
self.cpp_info.components["libcxx"].sharedlinkflags.extend(libcxx_build_flags)
self.cpp_info.components["libcxx"].exelinkflags.extend(libcxx_build_flags)
# if self._libcxx in ["libstdc++", "libstdc++11"]:
# self.cpp_info.libs.append("stdc++")
# elif "clang" in str(self.settings.compiler) and self._libcxx == "libc++":
# self.cpp_info.libs.append("c++")
# elif self._libcxx in ["c++_static", "c++_shared"]:
# self.cpp_info.libs.extend([self._libcxx, "c++abi"])
#self.cpp_info.cxxflags.extend(common_build_flags)
#self.cpp_info.cxxflags.extend(cxxflags)
#self.cpp_info.cflags.extend(common_build_flags)
#self.cpp_info.cflags.extend(cflags)
#self.cpp_info.sharedlinkflags.extend(common_link_flags)
#self.cpp_info.exelinkflags.extend(common_link_flags)
#self.cpp_info.sharedlinkflags.extend(ldflags)
#self.cpp_info.exelinkflags.extend(ldflags)
# NOTE: collects all flags, must be at the end
#self.env_info.CXXFLAGS = " ".join(self.cpp_info.cxxflags)
#self.env_info.LDFLAGS = " ".join(self.cpp_info.sharedlinkflags)