Skip to content

Commit bd589ee

Browse files
committed
Revert Makefile changes, rework all other ci additions.
1 parent a176bfb commit bd589ee

File tree

1,022 files changed

+197118
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,022 files changed

+197118
-0
lines changed

.github/workflows/libcpp.yml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
name: libcpp integration
2+
3+
on:
4+
workflow_dispatch:
5+
push:
6+
7+
concurrency:
8+
group: ${{ github.workflow }}-${{ github.ref }}
9+
cancel-in-progress: true
10+
11+
jobs:
12+
docker:
13+
runs-on: ubuntu-latest
14+
env:
15+
OUTPUT_LOCAL_DIR: libcpp-output
16+
STATUS_FILE: libcpp_status
17+
WASM_FILE_NAME: hello.cpp.wasm
18+
19+
steps:
20+
- name: Set up Docker Buildx
21+
uses: docker/setup-buildx-action@4d04d5d9486b7bd6fa91e7baf45bbb4f8b9deedd
22+
23+
- name: Build libcpp integration (attempt 1)
24+
id: build_libcpp_try1
25+
continue-on-error: true
26+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
27+
with:
28+
platforms: linux/amd64
29+
cache-from: type=gha
30+
cache-to: type=gha,mode=max
31+
file: Docker/Dockerfile.e2e
32+
target: libcpp-artifacts
33+
tags: libcpp-integration:latest
34+
outputs: type=local,dest=${{ env.OUTPUT_LOCAL_DIR }}
35+
36+
- name: Backoff (after try 1)
37+
if: ${{ always() && steps.build_libcpp_try1.outcome == 'failure' }}
38+
run: sleep 15
39+
40+
- name: Build libcpp integration (attempt 2)
41+
id: build_libcpp_try2
42+
if: ${{ always() && steps.build_libcpp_try1.outcome == 'failure' }}
43+
continue-on-error: true
44+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
45+
with:
46+
platforms: linux/amd64
47+
cache-from: type=gha
48+
cache-to: type=gha,mode=max
49+
file: Docker/Dockerfile.e2e
50+
target: libcpp-artifacts
51+
tags: libcpp-integration:latest
52+
outputs: type=local,dest=${{ env.OUTPUT_LOCAL_DIR }}
53+
54+
- name: Backoff (after try 2)
55+
if: ${{ always() && steps.build_libcpp_try2.outcome == 'failure' }}
56+
run: sleep 30
57+
58+
- name: Build libcpp integration (attempt 3)
59+
id: build_libcpp_try3
60+
if: ${{ always() && steps.build_libcpp_try2.outcome == 'failure' }}
61+
continue-on-error: true
62+
uses: docker/build-push-action@d08e5c354a6adb9ed34480a06d141179aa583294
63+
with:
64+
platforms: linux/amd64
65+
cache-from: type=gha
66+
cache-to: type=gha,mode=max
67+
file: Docker/Dockerfile.e2e
68+
target: libcpp-artifacts
69+
tags: libcpp-integration:latest
70+
outputs: type=local,dest=${{ env.OUTPUT_LOCAL_DIR }}
71+
72+
- name: Fail if all build attempts failed
73+
if: ${{ always() && steps.build_libcpp_try1.outcome == 'failure' && steps.build_libcpp_try2.outcome == 'failure' && steps.build_libcpp_try3.outcome == 'failure' }}
74+
run: |
75+
echo "All libcpp build attempts failed"
76+
exit 1
77+
78+
- name: Read libcpp status
79+
id: libcpp
80+
if: ${{ always() }}
81+
shell: bash
82+
run: |
83+
STATUS_PATH="${{ env.OUTPUT_LOCAL_DIR }}/${{ env.STATUS_FILE }}"
84+
echo "Checking status file at: $STATUS_PATH"
85+
echo "----- File contents (if any) -----"
86+
if [[ -f "$STATUS_PATH" ]]; then
87+
cat "$STATUS_PATH"
88+
cat "$STATUS_PATH" >> "$GITHUB_OUTPUT"
89+
cat "$STATUS_PATH" >> "$GITHUB_ENV"
90+
else
91+
echo "(none)"
92+
echo "LIBCPP_STATUS=fail" >> "$GITHUB_OUTPUT"
93+
echo "LIBCPP_STATUS=fail" >> "$GITHUB_ENV"
94+
echo "::warning file=$STATUS_PATH::Status file missing, defaulting to fail"
95+
fi
96+
echo "----------------------------------"
97+
98+
- name: Upload wasm artifact
99+
if: ${{ always() }}
100+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
101+
with:
102+
name: libcpp-wasm
103+
path: ${{ env.OUTPUT_LOCAL_DIR }}/${{ env.WASM_FILE_NAME }}
104+
if-no-files-found: error
105+
retention-days: 7
106+
107+
- name: Upload libcpp status artifact
108+
if: ${{ always() }}
109+
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f
110+
with:
111+
name: libcpp-status
112+
path: ${{ env.OUTPUT_LOCAL_DIR }}/${{ env.STATUS_FILE }}
113+
if-no-files-found: error
114+
retention-days: 7
115+
116+
- name: Fail if libcpp integration failed
117+
if: ${{ always() && steps.libcpp.outputs.LIBCPP_STATUS == 'fail' }}
118+
run: |
119+
echo "libcpp integration failed"
120+
exit 1

Docker/Dockerfile.libcpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Reuse the same base/build logic style as Dockerfile.e2e
2+
3+
FROM base AS build-libcpp
4+
5+
COPY . .
6+
7+
RUN make sysroot
8+
9+
RUN cp -r artifacts/include/wasm32-wasi/. build/sysroot/include/wasm32-wasi/ \
10+
&& cp -r artifacts/lib/wasm32-wasi/. build/sysroot/lib/wasm32-wasi/
11+
12+
RUN chmod +x scripts/lind_compile_cpp \
13+
&& rm -f trial/*.wasm \
14+
&& scripts/lind_compile_cpp trial/hello.cpp \
15+
&& test -n "$(find trial -maxdepth 1 -type f -name '*.wasm' | head -n 1)"
16+
17+
RUN mkdir -p /out \
18+
&& cp "$(find trial -maxdepth 1 -type f -name '*.wasm' | head -n 1)" /out/hello.cpp.wasm \
19+
&& printf '%s\n' 'LIBCPP_STATUS=pass' > /out/libcpp_status
20+
21+
FROM scratch
22+
COPY --from=build-libcpp /out/ /
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP___ALGORITHM_ADJACENT_FIND_H
11+
#define _LIBCPP___ALGORITHM_ADJACENT_FIND_H
12+
13+
#include <__algorithm/comp.h>
14+
#include <__algorithm/iterator_operations.h>
15+
#include <__config>
16+
#include <__iterator/iterator_traits.h>
17+
#include <__utility/move.h>
18+
19+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
20+
# pragma GCC system_header
21+
#endif
22+
23+
_LIBCPP_PUSH_MACROS
24+
#include <__undef_macros>
25+
26+
_LIBCPP_BEGIN_NAMESPACE_STD
27+
28+
template <class _Iter, class _Sent, class _BinaryPredicate>
29+
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _Iter
30+
__adjacent_find(_Iter __first, _Sent __last, _BinaryPredicate&& __pred) {
31+
if (__first == __last)
32+
return __first;
33+
_Iter __i = __first;
34+
while (++__i != __last) {
35+
if (__pred(*__first, *__i))
36+
return __first;
37+
__first = __i;
38+
}
39+
return __i;
40+
}
41+
42+
template <class _ForwardIterator, class _BinaryPredicate>
43+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
44+
adjacent_find(_ForwardIterator __first, _ForwardIterator __last, _BinaryPredicate __pred) {
45+
return std::__adjacent_find(std::move(__first), std::move(__last), __pred);
46+
}
47+
48+
template <class _ForwardIterator>
49+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 _ForwardIterator
50+
adjacent_find(_ForwardIterator __first, _ForwardIterator __last) {
51+
return std::adjacent_find(std::move(__first), std::move(__last), __equal_to());
52+
}
53+
54+
_LIBCPP_END_NAMESPACE_STD
55+
56+
_LIBCPP_POP_MACROS
57+
58+
#endif // _LIBCPP___ALGORITHM_ADJACENT_FIND_H
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP___ALGORITHM_ALL_OF_H
11+
#define _LIBCPP___ALGORITHM_ALL_OF_H
12+
13+
#include <__config>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
template <class _InputIterator, class _Predicate>
22+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
23+
all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24+
for (; __first != __last; ++__first)
25+
if (!__pred(*__first))
26+
return false;
27+
return true;
28+
}
29+
30+
_LIBCPP_END_NAMESPACE_STD
31+
32+
#endif // _LIBCPP___ALGORITHM_ALL_OF_H
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// -*- C++ -*-
2+
//===----------------------------------------------------------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP___ALGORITHM_ANY_OF_H
11+
#define _LIBCPP___ALGORITHM_ANY_OF_H
12+
13+
#include <__config>
14+
15+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
16+
# pragma GCC system_header
17+
#endif
18+
19+
_LIBCPP_BEGIN_NAMESPACE_STD
20+
21+
template <class _InputIterator, class _Predicate>
22+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
23+
any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred) {
24+
for (; __first != __last; ++__first)
25+
if (__pred(*__first))
26+
return true;
27+
return false;
28+
}
29+
30+
_LIBCPP_END_NAMESPACE_STD
31+
32+
#endif // _LIBCPP___ALGORITHM_ANY_OF_H
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___ALGORITHM_BINARY_SEARCH_H
10+
#define _LIBCPP___ALGORITHM_BINARY_SEARCH_H
11+
12+
#include <__algorithm/comp.h>
13+
#include <__algorithm/comp_ref_type.h>
14+
#include <__algorithm/lower_bound.h>
15+
#include <__config>
16+
#include <__iterator/iterator_traits.h>
17+
18+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
19+
# pragma GCC system_header
20+
#endif
21+
22+
_LIBCPP_BEGIN_NAMESPACE_STD
23+
24+
template <class _ForwardIterator, class _Tp, class _Compare>
25+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
26+
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value, _Compare __comp) {
27+
__first = std::lower_bound<_ForwardIterator, _Tp, __comp_ref_type<_Compare> >(__first, __last, __value, __comp);
28+
return __first != __last && !__comp(__value, *__first);
29+
}
30+
31+
template <class _ForwardIterator, class _Tp>
32+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
33+
binary_search(_ForwardIterator __first, _ForwardIterator __last, const _Tp& __value) {
34+
return std::binary_search(__first, __last, __value, __less<>());
35+
}
36+
37+
_LIBCPP_END_NAMESPACE_STD
38+
39+
#endif // _LIBCPP___ALGORITHM_BINARY_SEARCH_H
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//===----------------------------------------------------------------------===//
2+
//
3+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4+
// See https://llvm.org/LICENSE.txt for license information.
5+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6+
//
7+
//===----------------------------------------------------------------------===//
8+
9+
#ifndef _LIBCPP___ALGORITHM_CLAMP_H
10+
#define _LIBCPP___ALGORITHM_CLAMP_H
11+
12+
#include <__algorithm/comp.h>
13+
#include <__assert>
14+
#include <__config>
15+
16+
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
17+
# pragma GCC system_header
18+
#endif
19+
20+
_LIBCPP_BEGIN_NAMESPACE_STD
21+
22+
#if _LIBCPP_STD_VER >= 17
23+
template <class _Tp, class _Compare>
24+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
25+
clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
26+
_LIBCPP_LIFETIMEBOUND const _Tp& __lo,
27+
_LIBCPP_LIFETIMEBOUND const _Tp& __hi,
28+
_Compare __comp) {
29+
_LIBCPP_ASSERT_ARGUMENT_WITHIN_DOMAIN(!__comp(__hi, __lo), "Bad bounds passed to std::clamp");
30+
return __comp(__v, __lo) ? __lo : __comp(__hi, __v) ? __hi : __v;
31+
}
32+
33+
template <class _Tp>
34+
_LIBCPP_NODISCARD_EXT inline _LIBCPP_HIDE_FROM_ABI constexpr const _Tp&
35+
clamp(_LIBCPP_LIFETIMEBOUND const _Tp& __v,
36+
_LIBCPP_LIFETIMEBOUND const _Tp& __lo,
37+
_LIBCPP_LIFETIMEBOUND const _Tp& __hi) {
38+
return std::clamp(__v, __lo, __hi, __less<>());
39+
}
40+
#endif
41+
42+
_LIBCPP_END_NAMESPACE_STD
43+
44+
#endif // _LIBCPP___ALGORITHM_CLAMP_H

0 commit comments

Comments
 (0)