aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/cxxsupp/libcxx/.yandex_meta/build.ym
blob: be1ee0f8851b4bcae1f051e58b4ec7a73b36a457 (plain) (blame)
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
{% extends '//builtin/run.ym' %}

{% block current_version %}dc129d6f715cf83a2072fc8de8b4e4c70bca6935{% endblock %}
{% block current_date %}2023-10-05{% endblock %}

{% block keep_sources %}
.yandex_meta/scripts/sysincls.py
glibcxx_eh_cxx17.cpp
include/__config_site
include/__config_epilogue.h
include/__memory/pointer_safety.h
include/__support/win32/atomic_win32.h
include/math_cuda.h
include/stlfwd
include/unwind.h
include/use_ansi.h
src/support/win32/atomic_win32.cpp
src/support/win32/new_win32.cpp
{% endblock %}

{% block current_url %}
{% if not local_llvm %}
https://github.com/llvm/llvm-project/archive/{{self.version().strip()}}.tar.gz
{% endif %}
{% endblock %}

{% block init_bash %}
{{super()}}
SYSINCLS=${WORKDIR}/sysincls
{% endblock %}

{% block prepare_env %}
{{super()}}
{% if local_llvm %}
cp -R {{local_llvm.strip()}}/. ${RESOURCES}/
cd ${RESOURCES}
git checkout {{self.version().strip()}}
{% else %}
tar xf ${RESOURCES}/{{self.current_url().strip() | basename}} --strip-components=1 --directory=${RESOURCES}
{% endif %}
base64 -d << EOF > ${BIN}/sysincls
{% include 'scripts/sysincls.py/base64' %}

EOF
mkdir -p ${SYSINCLS}
base64 -d << EOF > ${SYSINCLS}/stl-to-libcxx.yml
{% include '//build/sysincl/stl-to-libcxx.yml/base64' %}

EOF

chmod +x ${BIN}/sysincls
{% endblock %}

{% block unpack_source %}
{{super()}}
rsync --recursive ${RESOURCES}/libcxx/include .
rsync --recursive ${RESOURCES}/libcxx/src .
cp ${RESOURCES}/libcxx/.clang-format .
cp ${RESOURCES}/libcxx/CREDITS.TXT .
cp ${RESOURCES}/libcxx/LICENSE.TXT .
{% endblock %}

{% block build_source %}
{{super()}}
rm src/CMakeLists.txt include/CMakeLists.txt

sysincls ${SRC} ${SYSINCLS}/stl-to-libcxx.yml
{% endblock %}


{% block prepare_yamake %}
cat << EOF > ya.make
# Generated by devtools/yamaker/ym2

LIBRARY()

LICENSE(
    Apache-2.0 AND
    Apache-2.0 WITH LLVM-exception AND
    BSL-1.0 AND
    MIT AND
    NCSA AND
    Unicode
)

LICENSE_TEXTS(.yandex_meta/licenses.list.txt)

VERSION({{self.date().strip()}})

ORIGINAL_SOURCE(https://github.com/llvm/llvm-project/archive/{{self.version().strip()}}.tar.gz)

SUBSCRIBER(
    halyavin
    somov
    g:cpp-committee
    g:cpp-contrib
)

ADDINCL(
    GLOBAL contrib/libs/cxxsupp/libcxx/include
    contrib/libs/cxxsupp/libcxx/src
)

CXXFLAGS(-D_LIBCPP_BUILDING_LIBRARY)

IF (OS_ANDROID)
    DEFAULT(CXX_RT "default")
    IF (ARCH_I686 OR ARCH_ARM7)
        # 32-bit architectures require additional libandroid_support.so to be linked
        # We add --start-group / --end-group statements due to the issue in NDK < r22.
        # See: https://github.com/android/ndk/issues/1130
        #
        # Though these statements are not respected by LLD, they might have sense for other linkers.
        LDFLAGS(
            -Wl,--start-group
            -lc++abi
            -landroid_support
            -Wl,--end-group
        )
    ELSE()
        LDFLAGS(-lc++abi)
    ENDIF()
    CFLAGS(
        -DLIBCXX_BUILDING_LIBCXXABI
    )
# Take cxxabi implementation from system.
ELSEIF (OS_IOS)
    LDFLAGS(-lc++abi)
    CFLAGS(
        -DLIBCXX_BUILDING_LIBCXXABI
    )
    # Yet take builtins library from Arcadia
    PEERDIR(
        contrib/libs/cxxsupp/builtins
    )
ELSEIF (OS_LINUX OR OS_DARWIN)
    IF (ARCH_ARM7)
        # XXX: libcxxrt support for ARM is currently broken
        DEFAULT(CXX_RT "glibcxx_static")
        # ARM7 OS_SDK has old libstdc++ without aligned allocation support
        CFLAGS(
            GLOBAL -fno-aligned-new
        )
    ELSE()
        DEFAULT(CXX_RT "libcxxrt")
    ENDIF()
    IF (MUSL)
        PEERDIR(
            contrib/libs/musl/include
        )
    ENDIF()
ELSEIF (OS_WINDOWS)
    SRCS(
        src/support/win32/locale_win32.cpp
        src/support/win32/support.cpp
        src/support/win32/atomic_win32.cpp
        src/support/win32/new_win32.cpp
        src/support/win32/thread_win32.cpp
    )
    CFLAGS(
        GLOBAL -D_LIBCPP_VASPRINTF_DEFINED
        GLOBAL -D_WCHAR_H_CPLUSPLUS_98_CONFORMANCE_
    )
    IF (CLANG_CL)
        PEERDIR(
            contrib/libs/cxxsupp/builtins
        )
    ENDIF()
ELSEIF (OS_EMSCRIPTEN)
    DEFAULT(CXX_RT "libcxxabi")
    LDFLAGS(
        -Wl,-Bdynamic
    )
    CXXFLAGS(
        -Wno-unknown-pragmas
        -nostdinc++
    )
    PEERDIR(
        contrib/restricted/emscripten/include
    )
ELSE()
    DEFAULT(CXX_RT "glibcxx_static")
    CXXFLAGS(
        -Wno-unknown-pragmas
        -nostdinc++
    )
ENDIF()

IF (OS_LINUX)
    EXTRALIBS(-lpthread)
ENDIF()

IF (CLANG)
    CXXFLAGS(GLOBAL -nostdinc++)
ENDIF()

# The CXX_RT variable controls which C++ runtime is used.
# * libcxxrt        - https://github.com/libcxxrt/libcxxrt library stored in Arcadia
# * glibcxx_static  - GNU C++ Library runtime with static linkage
# * glibcxx_dynamic - GNU C++ Library runtime with dynamic linkage
# * default         - default C++ runtime provided by the compiler driver
#
# All glibcxx* runtimes are taken from system/compiler SDK

DEFAULT(CXX_RT "default")

DISABLE(NEED_GLIBCXX_CXX17_SHIMS)

DISABLE(NEED_CXX_RT_ADDINCL)

IF (CXX_RT == "libcxxrt")
    PEERDIR(
        contrib/libs/cxxsupp/libcxxabi-parts
        contrib/libs/cxxsupp/libcxxrt
        contrib/libs/cxxsupp/builtins
    )
    ADDINCL(
        GLOBAL contrib/libs/cxxsupp/libcxxrt/include
    )
    CFLAGS(
        GLOBAL -DLIBCXX_BUILDING_LIBCXXRT
    )
    # These builtins are equivalent to clang -rtlib=compiler_rt and
    # are needed by potentially any code generated by clang.
    # With glibcxx runtime, builtins are provided by libgcc
ELSEIF (CXX_RT == "glibcxx_static")
    LDFLAGS(
        -Wl,-Bstatic
        -lsupc++
        -lgcc
        -lgcc_eh
        -Wl,-Bdynamic
    )
    CXXFLAGS(-D__GLIBCXX__=1)
    ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
    ENABLE(NEED_CXX_RT_ADDINCL)
    CFLAGS(
        GLOBAL -DLIBCXX_BUILDING_LIBGCC
    )
ELSEIF (CXX_RT == "glibcxx_dynamic")
    LDFLAGS(
        -lgcc_s
        -lstdc++
    )
    CXXFLAGS(-D__GLIBCXX__=1)
    CFLAGS(
        GLOBAL -DLIBCXX_BUILDING_LIBGCC
    )
    ENABLE(NEED_GLIBCXX_CXX17_SHIMS)
    ENABLE(NEED_CXX_RT_ADDINCL)
ELSEIF (CXX_RT == "libcxxabi")
    PEERDIR(
        contrib/libs/cxxsupp/libcxxabi
    )
    ADDINCL(
        GLOBAL contrib/libs/cxxsupp/libcxxabi/include
    )
    CFLAGS(
        GLOBAL -DLIBCXX_BUILDING_LIBCXXABI
    )
ELSEIF (CXX_RT == "default")
# Do nothing
ELSE()
    MESSAGE(FATAL_ERROR "Unexpected CXX_RT value: \${CXX_RT}")
ENDIF()

IF (NEED_GLIBCXX_CXX17_SHIMS)
    IF (GCC)
        # Assume GCC is bundled with a modern enough version of C++ runtime
    ELSEIF (OS_SDK == "ubuntu-12" OR OS_SDK == "ubuntu-14" OR OS_SDK == "ubuntu-16")
        # Prior to ubuntu-18, system C++ runtime for C++17 is incomplete
        # and requires std::uncaught_exceptions() to be implemented.
        SRCS(
            glibcxx_eh_cxx17.cpp
        )
    ENDIF()
ENDIF()

IF (NEED_CXX_RT_ADDINCL)
    # FIXME:
    # This looks extremely weird and we have to use cxxabi.h from libsupc++ instead.
    # This ADDINCL is placed here just to fix the status quo
    ADDINCL(
        GLOBAL contrib/libs/cxxsupp/libcxxrt/include
    )
ENDIF()

NO_UTIL()

NO_RUNTIME()

NO_COMPILER_WARNINGS()

IF (FUZZING)
    NO_SANITIZE()
    NO_SANITIZE_COVERAGE()
ENDIF()

SRCS(
    src/algorithm.cpp
    src/any.cpp
    src/atomic.cpp
    src/barrier.cpp
    src/bind.cpp
    src/charconv.cpp
    src/chrono.cpp
    src/condition_variable.cpp
    src/condition_variable_destructor.cpp
    src/error_category.cpp
    src/exception.cpp
    src/filesystem/directory_entry.cpp
    src/filesystem/directory_iterator.cpp
    src/filesystem/filesystem_clock.cpp
    src/filesystem/filesystem_error.cpp
    src/filesystem/operations.cpp
    src/filesystem/path.cpp
    src/functional.cpp
    src/future.cpp
    src/hash.cpp
    src/ios.cpp
    src/ios.instantiations.cpp
    src/iostream.cpp
    src/legacy_pointer_safety.cpp
    src/locale.cpp
    src/memory.cpp
    src/memory_resource.cpp
    src/mutex.cpp
    src/mutex_destructor.cpp
    src/optional.cpp
    src/print.cpp
    src/random.cpp
    src/random_shuffle.cpp
    src/regex.cpp
    src/ryu/d2fixed.cpp
    src/ryu/d2s.cpp
    src/ryu/f2s.cpp
    src/shared_mutex.cpp
    src/stdexcept.cpp
    src/string.cpp
    src/strstream.cpp
    src/system_error.cpp
    src/thread.cpp
    src/typeinfo.cpp
    src/valarray.cpp
    src/variant.cpp
    src/vector.cpp
    src/verbose_abort.cpp
)

IF (NOT OS_WINDOWS)
    SRCS(
        src/new.cpp
        src/new_handler.cpp
        src/new_helpers.cpp
    )
ENDIF()

IF (OS_LINUX)
    SRCS(
        src/tz.cpp
        src/tzdb_list.cpp
    )
ENDIF()

END()
EOF
{% endblock %}

{% block update_version %}
echo "no version update"
{% endblock %}

{% block move_to_output %}
rsync --recursive --delete --perms ${SRC}/ ${OUTPUT}
{% endblock %}


{% block step_install %}
{{super()}}
rsync ${SYSINCLS}/stl-to-libcxx.yml ${ARCADIA_ROOT}/build/sysincl/stl-to-libcxx.yml
{% endblock %}