Skip to content

Commit bcf26cb

Browse files
committed
Solve issues on docker, improbe build warnings.
1 parent 44379ca commit bcf26cb

File tree

19 files changed

+186
-87
lines changed

19 files changed

+186
-87
lines changed

.github/workflows/docker-hub.yml

Lines changed: 10 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -67,42 +67,32 @@ jobs:
6767
run: |
6868
./docker-compose.sh platform
6969
70-
- name: Tag Platform Images
71-
run: |
72-
set -exuo pipefail
73-
platform_tag=$(echo "${{ matrix.platform }}" | tr '/' '-')
74-
echo "Platform Tag: ${platform_tag}"
75-
for tag in "deps" "dev" "runtime" "cli"; do
76-
docker tag metacall/${IMAGE_NAME}:${tag} \
77-
metacall/${IMAGE_NAME}:${tag}-${platform_tag}
78-
docker tag metacall/${IMAGE_NAME}:${tag} \
79-
${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}-${platform_tag}
80-
done
81-
8270
- name: Run Tests
8371
run: |
8472
set -exuo pipefail
85-
platform_tag=$(echo "${{ matrix.platform }}" | tr '/' '-')
86-
docker image inspect metacall/${IMAGE_NAME}:cli-${platform_tag} --format='{{.Os}}/{{.Architecture}}'
73+
docker image inspect ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:cli --format='{{.Os}}/{{.Architecture}}'
8774
cat <<EOF > Dockerfile.test
88-
FROM metacall/${IMAGE_NAME}:cli-${platform_tag}
89-
RUN echo "console.log('0123456789abcdef')" > script.js
90-
RUN apt-get update && apt-get install file
75+
FROM ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:cli
76+
RUN apt-get update && apt-get install -y file
9177
RUN file /usr/local/bin/metacallcli
92-
RUN /usr/local/bin/metacallcli /usr/local/scripts/script.js
93-
RUN /usr/local/bin/metacallcli script.js | tee output.txt
78+
RUN echo "console.log('0123456789abcdef')" > script.js
79+
RUN metacallcli script.js | tee output.txt
9480
RUN grep 0123456789abcdef output.txt
9581
EOF
9682
9783
export DOCKER_BUILDKIT=1
9884
docker build --progress=plain --platform=${{ matrix.platform }} -f Dockerfile.test -t test-image .
9985
100-
- name: Push Platform Images
86+
- name: Tag & Push Platform Images
10187
# Only run when master or when tagging a version
10288
if: (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/tags/')) && github.event_name != 'pull_request'
10389
run: |
10490
platform_tag=$(echo "${{ matrix.platform }}" | tr '/' '-')
10591
for tag in "deps" "dev" "runtime" "cli"; do
92+
docker tag \
93+
${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag} \
94+
${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}-${platform_tag}
95+
10696
echo "Pushing image for tag: ${tag} with platform: ${platform_tag}"
10797
docker push ${DOCKER_REGISTRY}/${DOCKER_USERNAME}/${IMAGE_NAME}:${tag}-${platform_tag}
10898
done

docker-compose.test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@ services:
2525
build:
2626
args:
2727
METACALL_BUILD_TYPE: ${METACALL_BUILD_TYPE}
28-
METACALL_INSTALL_OPTIONS: base python ruby netcore7 nodejs typescript file rpc wasm java c cobol go rust rapidjson swig pack backtrace sandbox ${METACALL_BUILD_COVERAGE} # clangformat v8rep51
28+
METACALL_INSTALL_OPTIONS: base python ruby netcore8 nodejs typescript file rpc wasm java c cobol go rust rapidjson swig pack backtrace sandbox ${METACALL_BUILD_COVERAGE} # clangformat v8rep51
2929
dev:
3030
image: metacall/core:dev
3131
build:
3232
args:
3333
METACALL_BUILD_TYPE: ${METACALL_BUILD_TYPE}
34-
METACALL_BUILD_OPTIONS: ${METACALL_BUILD_SANITIZER} python ruby netcore7 nodejs typescript file rpc wasm java c cobol go rust examples tests scripts ports install pack sandbox benchmarks ${METACALL_BUILD_COVERAGE} # v8
34+
METACALL_BUILD_OPTIONS: ${METACALL_BUILD_SANITIZER} python ruby netcore8 nodejs typescript file rpc wasm java c cobol go rust examples tests scripts ports install pack sandbox benchmarks ${METACALL_BUILD_COVERAGE} # v8

source/loaders/node_loader/include/node_loader/node_loader_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ NODE_LOADER_NO_EXPORT void node_loader_impl_destroy_safe_impl(loader_impl_node n
6767

6868
NODE_LOADER_NO_EXPORT void node_loader_impl_print_handles(loader_impl_node node_impl);
6969

70-
NODE_LOADER_NO_EXPORT int64_t node_loader_impl_user_async_handles_count(loader_impl_node node_impl);
70+
NODE_LOADER_NO_EXPORT uint64_t node_loader_impl_user_async_handles_count(loader_impl_node node_impl);
7171

7272
NODE_LOADER_NO_EXPORT napi_value node_loader_impl_register_bootstrap_startup(loader_impl_node node_impl, napi_env env);
7373

source/loaders/node_loader/source/node_loader_impl.cpp

Lines changed: 45 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -704,8 +704,8 @@ struct loader_impl_node_type
704704
/* TODO: This implementation won't work for multi-isolate environments. We should test it. */
705705
std::thread::id js_thread_id;
706706

707-
int64_t base_active_handles;
708-
std::atomic_int64_t extra_active_handles;
707+
uint64_t base_active_handles;
708+
std::atomic_uint64_t extra_active_handles;
709709
uv_prepare_t destroy_prepare;
710710
uv_check_t destroy_check;
711711
std::atomic_bool event_loop_empty;
@@ -874,7 +874,7 @@ static void node_loader_impl_thread_log(void *data);
874874
static void node_loader_impl_walk_async_handles_count(uv_handle_t *handle, void *arg);
875875
#endif
876876

877-
static int64_t node_loader_impl_async_handles_count(loader_impl_node node_impl);
877+
static uint64_t node_loader_impl_async_handles_count(loader_impl_node node_impl);
878878

879879
static void node_loader_impl_try_destroy(loader_impl_node node_impl);
880880

@@ -4346,7 +4346,7 @@ static void node_loader_impl_destroy_cb(loader_impl_node node_impl)
43464346
node_loader_impl_print_handles(node_impl);
43474347
#endif
43484348

4349-
if (node_impl->event_loop_empty.load() == false && node_loader_impl_user_async_handles_count(node_impl) <= 0)
4349+
if (node_impl->event_loop_empty.load() == false && node_loader_impl_user_async_handles_count(node_impl) == 0)
43504350
{
43514351
loader_impl_handle_safe_cast<uv_prepare_t> destroy_prepare_cast = { NULL };
43524352
loader_impl_handle_safe_cast<uv_check_t> destroy_check_cast = { NULL };
@@ -4399,7 +4399,7 @@ void node_loader_impl_destroy_safe(napi_env env, loader_impl_async_destroy_safe_
43994399
node_loader_impl_exception(env, status);
44004400

44014401
/* Check if there are async handles, destroy if the queue is empty, otherwise request the destroy */
4402-
if (node_loader_impl_user_async_handles_count(node_impl) <= 0 || node_impl->event_loop_empty.load() == true)
4402+
if (node_loader_impl_user_async_handles_count(node_impl) == 0 || node_impl->event_loop_empty.load() == true)
44034403
{
44044404
node_loader_impl_destroy_safe_impl(node_impl, env);
44054405
destroy_safe->has_finished = true;
@@ -4431,7 +4431,7 @@ static inline int uv__queue_empty(const struct node_loader_impl_uv__queue *q)
44314431
#if (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)
44324432
void node_loader_impl_walk_async_handles_count(uv_handle_t *handle, void *arg)
44334433
{
4434-
int64_t *async_count = static_cast<int64_t *>(arg);
4434+
uint64_t *async_count = static_cast<uint64_t *>(arg);
44354435

44364436
if (uv_is_active(handle) && !uv_is_closing(handle))
44374437
{
@@ -4447,11 +4447,11 @@ void node_loader_impl_walk_async_handles_count(uv_handle_t *handle, void *arg)
44474447
}
44484448
#endif
44494449

4450-
int64_t node_loader_impl_async_closing_handles_count(loader_impl_node node_impl)
4450+
uint64_t node_loader_impl_async_closing_handles_count(loader_impl_node node_impl)
44514451
{
44524452
#if defined(WIN32) || defined(_WIN32)
4453-
return (int64_t)(node_impl->thread_loop->pending_reqs_tail != NULL) +
4454-
(int64_t)(node_impl->thread_loop->endgame_handles != NULL);
4453+
return (uint64_t)(node_impl->thread_loop->pending_reqs_tail != NULL) +
4454+
(uint64_t)(node_impl->thread_loop->endgame_handles != NULL);
44554455
#else
44564456
union
44574457
{
@@ -4461,49 +4461,66 @@ int64_t node_loader_impl_async_closing_handles_count(loader_impl_node node_impl)
44614461

44624462
uv__queue_cast.data = (void *)&node_impl->thread_loop->pending_queue;
44634463

4464-
return (int64_t)(!uv__queue_empty(uv__queue_cast.ptr)) +
4465-
(int64_t)(node_impl->thread_loop->closing_handles != NULL);
4464+
return (uint64_t)(!uv__queue_empty(uv__queue_cast.ptr)) +
4465+
(uint64_t)(node_impl->thread_loop->closing_handles != NULL);
44664466
#endif
44674467
}
44684468

4469-
int64_t node_loader_impl_async_handles_count(loader_impl_node node_impl)
4469+
uint64_t node_loader_impl_async_handles_count(loader_impl_node node_impl)
44704470
{
44714471
#if (defined(__APPLE__) && defined(__MACH__)) || defined(__MACOSX__)
4472-
int64_t active_handles = 0;
4472+
uint64_t active_handles = 0;
44734473
uv_walk(node_impl->thread_loop, node_loader_impl_walk_async_handles_count, (void *)&active_handles);
44744474

44754475
return active_handles +
4476-
(int64_t)(node_impl->thread_loop->active_reqs.count > 0) +
4476+
(uint64_t)(node_impl->thread_loop->active_reqs.count > 0) +
44774477
node_loader_impl_async_closing_handles_count(node_impl);
44784478
#else
4479-
int64_t active_handles = (int64_t)node_impl->thread_loop->active_handles +
4480-
(int64_t)(node_impl->thread_loop->active_reqs.count > 0) +
4481-
node_loader_impl_async_closing_handles_count(node_impl);
4479+
uint64_t active_handles = (uint64_t)node_impl->thread_loop->active_handles +
4480+
(uint64_t)(node_impl->thread_loop->active_reqs.count > 0) +
4481+
node_loader_impl_async_closing_handles_count(node_impl);
44824482
return active_handles;
44834483
#endif
44844484
}
44854485

4486-
int64_t node_loader_impl_user_async_handles_count(loader_impl_node node_impl)
4486+
uint64_t node_loader_impl_user_async_handles_count(loader_impl_node node_impl)
44874487
{
4488-
int64_t active_handles = node_loader_impl_async_handles_count(node_impl);
4489-
int64_t extra_active_handles = node_impl->extra_active_handles.load();
4488+
uint64_t active_handles = node_loader_impl_async_handles_count(node_impl);
4489+
uint64_t extra_active_handles = node_impl->extra_active_handles.load();
4490+
uint64_t base_active_handles = node_impl->base_active_handles;
44904491

44914492
/* TODO: Uncomment for debugging handles */
44924493
/*
44934494
#if (!defined(NDEBUG) || defined(DEBUG) || defined(_DEBUG) || defined(__DEBUG) || defined(__DEBUG__))
4494-
int64_t closing = node_loader_impl_async_closing_handles_count(node_impl);
4495+
uint64_t closing = node_loader_impl_async_closing_handles_count(node_impl);
44954496
44964497
printf("[active_handles] - [base_active_handles] - [extra_active_handles] + [active_reqs] + [closing]\n");
4497-
printf(" %" PRId64 " - %" PRId64 " - %" PRId64 " + %" PRId64 " [> 0] + %" PRId64 "\n",
4498-
(int64_t)node_impl->thread_loop->active_handles,
4499-
node_impl->base_active_handles,
4498+
printf(" %" PRIu64 " - %" PRIu64 " - %" PRIu64 " + %" PRIu64 " [> 0] + %" PRIu64 "\n",
4499+
(uint64_t)node_impl->thread_loop->active_handles,
4500+
base_active_handles,
45004501
extra_active_handles,
4501-
(int64_t)node_impl->thread_loop->active_reqs.count,
4502+
(uint64_t)node_impl->thread_loop->active_reqs.count,
45024503
closing);
45034504
#endif
45044505
*/
45054506

4506-
return active_handles - node_impl->base_active_handles - extra_active_handles;
4507+
/* Check for overflow */
4508+
uint64_t total_base_handles = base_active_handles + extra_active_handles;
4509+
4510+
if (total_base_handles < base_active_handles)
4511+
{
4512+
/* Overflow occurred */
4513+
return UINT64_MAX;
4514+
}
4515+
4516+
/* Check for underflow */
4517+
if (active_handles < total_base_handles)
4518+
{
4519+
/* Underflow occurred */
4520+
return 0;
4521+
}
4522+
4523+
return active_handles - total_base_handles;
45074524
}
45084525

45094526
void node_loader_impl_print_handles(loader_impl_node node_impl)
@@ -4512,8 +4529,8 @@ void node_loader_impl_print_handles(loader_impl_node node_impl)
45124529

45134530
/* TODO: Uncomment for debugging handles */
45144531
/*
4515-
printf("Number of active handles: %" PRId64 "\n", node_loader_impl_async_handles_count(node_impl));
4516-
printf("Number of user active handles: %" PRId64 "\n", node_loader_impl_user_async_handles_count(node_impl));
4532+
printf("Number of active handles: %" PRIu64 "\n", node_loader_impl_async_handles_count(node_impl));
4533+
printf("Number of user active handles: %" PRIu64 "\n", node_loader_impl_user_async_handles_count(node_impl));
45174534
uv_print_active_handles(node_impl->thread_loop, stdout);
45184535
fflush(stdout);
45194536
*/

source/loaders/node_loader/source/node_loader_trampoline.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,12 +397,17 @@ napi_value node_loader_trampoline_active_handles(napi_env env, napi_callback_inf
397397
return nullptr;
398398
}
399399

400-
int64_t active_handles = node_loader_impl_user_async_handles_count(node_impl_cast.data);
400+
uint64_t active_handles = node_loader_impl_user_async_handles_count(node_impl_cast.data);
401401

402402
/* Create the integer return value */
403403
napi_value result;
404404

405-
status = napi_create_int64(env, active_handles, &result);
405+
if (active_handles > (uint64_t)INT64_MAX)
406+
{
407+
active_handles = (uint64_t)INT64_MAX;
408+
}
409+
410+
status = napi_create_int64(env, (int64_t)active_handles, &result);
406411

407412
node_loader_impl_exception(env, status);
408413

source/loaders/py_loader/source/py_loader_dict.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,32 @@
2626
#include <Python.h>
2727

2828
#if PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 13
29+
/* Disable warnings from Python */
30+
#if defined(__clang__)
31+
#pragma clang diagnostic push
32+
#pragma clang diagnostic ignored "-Wredundant-decls"
33+
#pragma clang diagnostic ignored "-Wstrict-aliasing"
34+
#pragma clang diagnostic ignored "-Wunused-parameter"
35+
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
36+
#elif defined(__GNUC__)
37+
#pragma GCC diagnostic push
38+
#pragma GCC diagnostic ignored "-Wredundant-decls"
39+
#pragma GCC diagnostic ignored "-Wstrict-aliasing"
40+
#pragma GCC diagnostic ignored "-Wunused-parameter"
41+
#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
42+
#endif
43+
2944
#ifndef Py_BUILD_CORE
3045
#define Py_BUILD_CORE
3146
#endif
3247
#include <internal/pycore_dict.h>
48+
49+
/* Disable warnings from Python */
50+
#if defined(__clang__)
51+
#pragma clang diagnostic pop
52+
#elif defined(__GNUC__)
53+
#pragma GCC diagnostic pop
54+
#endif
3355
#endif
3456

3557
struct py_loader_impl_dict_obj

source/loaders/py_loader/source/py_loader_impl.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@
4444
#include <stdbool.h>
4545
#include <stdlib.h>
4646

47-
#include <Python.h>
48-
4947
#define PY_LOADER_IMPL_FUNCTION_TYPE_INVOKE_FUNC "__py_loader_impl_function_type_invoke__"
5048
#define PY_LOADER_IMPL_FINALIZER_FUNC "__py_loader_impl_finalizer__"
5149

source/loaders/py_loader/source/py_loader_threading.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424

2525
#include <Python.h>
2626

27-
#include <thread>
28-
2927
struct py_thread_state
3028
{
3129
uint64_t ref_count;

source/loaders/rb_loader/source/rb_loader_impl.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#pragma GCC diagnostic push
4343
#pragma GCC diagnostic ignored "-Wredundant-decls"
4444
#pragma GCC diagnostic ignored "-Wpedantic"
45+
#pragma GCC diagnostic ignored "-Wunused-parameter"
4546
#endif
4647

4748
#include <ruby.h>

source/ports/py_port/helper.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ def pre_install(components):
112112
def pre_install_prompt():
113113

114114
answers = {'yes': True, 'y': True, 'no': False, 'n': False}
115-
components = ['python', 'ruby', 'netcore7', 'v8', 'nodejs', 'ports']
115+
components = ['python', 'ruby', 'netcore8', 'v8', 'nodejs', 'ports']
116116
args = []
117117

118118
try:

0 commit comments

Comments
 (0)