Skip to content

Commit 83f8682

Browse files
Can Run ACE/tests/run_test.pl, Got OS_Test Passing
Almost all other ACE tests are failing pretty spectacularly though. Also fixed some build warnings and added instructions to ACE-INSTALL.
1 parent 8876bc7 commit 83f8682

File tree

8 files changed

+103
-18
lines changed

8 files changed

+103
-18
lines changed

ACE/ACE-INSTALL.html

+39-1
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,7 @@ <h1><a name="aceinstall">Building and Installing ACE</a></h1>
284284
<li><a href="#win32">Windows (including MinGW and Cygwin)</a></li>
285285
<li><a href="#vxworks">VxWorks</a></li>
286286
<li><a href="#android">Android</a></li>
287+
<li><a href="#emscripten">Emscripten WebAssembly</a></li>
287288
</ul>
288289

289290
<h2>General Rules</h2>
@@ -1823,7 +1824,7 @@ <h3><a name="android-openssl">OpenSSL</a></h3>
18231824
OpenSSL. On Android, OpenSSL isn't part of the NDK Library and Android
18241825
preloads the system SSL library (either OpenSSL or BoringSSL) for the Java
18251826
Android API. This means OpenSSL <b>MUST</b> be statically linked to avoid
1826-
conflicts with the almost certianly incompatible system SSL library.
1827+
conflicts with the almost certainly incompatible system SSL library.
18271828

18281829
To build OpenSSL for Android, please read <code>NOTES.ANDROID</code> that comes
18291830
with OpenSSL's source code. The static libraries will used if the shared
@@ -1833,6 +1834,43 @@ <h3><a name="android-openssl">OpenSSL</a></h3>
18331834
building OpenSSL.
18341835
</p>
18351836

1837+
<hr align="left" width="50%">
1838+
1839+
<h2><a name="emscripten">Building ACE for Emscripten WebAssembly</a></h2>
1840+
1841+
<p><b>NOTE: This has only been tested on Linux with NodeJS 16.18.</b></p>
1842+
1843+
<a href="https://emscripten.org/">Emscripten</a>
1844+
is a LLVM toolchain that allows compiling C++ to
1845+
<a href="https://en.wikipedia.org/wiki/WebAssembly">WebAssembly</a>
1846+
that can be ran on a web browser or <a href="https://nodejs.org">NodeJS</a>.
1847+
1848+
<h3>Building</h3>
1849+
1850+
<ol>
1851+
<li>Download and setup <a href="https://emscripten.org/docs/getting_started/downloads.html">emscripten</a>.</li>
1852+
<li>Run <code>source emsdk_env.sh</code> in <code>emsdk</code>.</li>
1853+
<li>Make sure MPC is available and <code>MPC_ROOT</code> is set.</li>
1854+
<li>Configure ACE:
1855+
<ol>
1856+
<li><code>$ACE_ROOT/bin/MakeProjectCreator/config/default.features</code>
1857+
should contain <code>no_cxx11=0</code></li>
1858+
<li><code>$ACE_ROOT/include/makeinclude/platform_macros.GNU</code> should contain
1859+
<code>include $(ACE_ROOT)/include/makeinclude/platform_emscripten.GNU</code></li>
1860+
<li><code>$ACE_ROOT/ace/config.h</code> should contain
1861+
<code>#include "config-emscripten.h"</code></li>
1862+
<li><code>cd $ACE_ROOT/ace &amp;&amp; mwc.pl -type gnuace .</code></li>
1863+
</ol>
1864+
</li>
1865+
<li>Build ACE: <code>cd $ACE_ROOT/ace &amp;&amp; make -j4</code></li>
1866+
</ol>
1867+
1868+
<h3>Running Tests</h3>
1869+
1870+
<pre class="indent">
1871+
DOC_TEST_1=NODEJS NODEJS_OS=local ./run_test.pl -Config STATIC -Config NODEJS
1872+
</pre>
1873+
18361874
<hr>
18371875
<h1><a name="svcsinstall">Building and Installing ACE Network Services</a></h1>
18381876

ACE/ace/config-emscripten.h

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,13 @@
4040
#define ACE_HAS_DIRENT
4141
#define ACE_HAS_4_4BSD_SENDMSG_RECVMSG
4242

43+
// These exist, but don't seem to work correctly
44+
#define ACE_LACKS_PWD_FUNCTIONS
45+
4346
#include "config-posix.h"
4447
#include "config-g++-common.h"
4548

46-
// Not supported? https://github.com/emscripten-core/emscripten/issues/18050
49+
// Not supported: https://github.com/emscripten-core/emscripten/issues/18050
4750
#ifdef ACE_HAS_AIO_CALLS
4851
# undef ACE_HAS_AIO_CALLS
4952
#endif

ACE/bin/PerlACE/ProcessNodeJS.pm

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package PerlACE::ProcessNodeJS;
2+
3+
use strict;
4+
5+
use PerlACE::Process;
6+
our @ISA = qw(PerlACE::Process);
7+
8+
sub new {
9+
my $class = shift();
10+
my $name = shift();
11+
my $args = shift();
12+
my $node_args = shift() // '';
13+
14+
my $self = $class->SUPER::new("$name.js", $node_args);
15+
bless($self, $class);
16+
$self->IgnoreExeSubDir(1);
17+
$self->{VALGRIND_CMD} = "node $node_args";
18+
return $self;
19+
}
20+
21+
1;

ACE/bin/PerlACE/Run_Test.pm

+5
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ if ($PerlACE::Android_Test) {
4848
require PerlACE::ProcessAndroid;
4949
}
5050

51+
$PerlACE::NodeJS_Test = $config->check_config("NODEJS");
52+
if ($PerlACE::NodeJS_Test) {
53+
require PerlACE::ProcessNodeJS;
54+
}
55+
5156
# Figure out the svc.conf extension
5257
$svcconf_ext = $ENV{'ACE_RUNTEST_SVCCONF_EXT'};
5358
if (!defined $svcconf_ext) {

ACE/bin/PerlACE/TestTarget.pm

+18-10
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ sub new
8282
{
8383
my $proto = shift;
8484
my $class = ref ($proto) || $proto;
85-
my $self = {};
86-
8785
my $config_name = shift;
86+
87+
my $self = {config_name => $config_name};
88+
8889
bless ($self, $class);
8990
$self->GetConfigSettings($config_name);
9091

@@ -505,7 +506,7 @@ sub DeleteFile ($)
505506
print STDERR "Deleting remote $file from path $newfile using $cmd\n";
506507
}
507508
if (system ($cmd) != 0) {
508-
print STDERR "ERROR executing [".$cmd."]\n";
509+
print STDERR "ERROR executing [".$cmd."]\n";
509510
}
510511
} else {
511512
unlink ($newfile);
@@ -523,9 +524,9 @@ sub GetFile ($)
523524
$remote_file = $self->LocalFile($local_file);
524525
}
525526
if (defined $self->{GET_CMD}) {
526-
if (system ($self->{GET_CMD}.' '.$remote_file.' '.$local_file) != 0) {
527-
print STDERR "ERROR executing [".$self->{GET_CMD}." $remote_file $local_file]\n";
528-
}
527+
if (system ($self->{GET_CMD}.' '.$remote_file.' '.$local_file) != 0) {
528+
print STDERR "ERROR executing [".$self->{GET_CMD}." $remote_file $local_file]\n";
529+
}
529530
}
530531
elsif (($remote_file ne $local_file) &&
531532
(File::Spec->rel2abs($remote_file) ne File::Spec->rel2abs($local_file))) {
@@ -541,9 +542,9 @@ sub PutFile ($)
541542
my $src = shift;
542543
my $dest = $self->LocalFile ($src);
543544
if (defined $self->{PUT_CMD}) {
544-
if (system ($self->{PUT_CMD}.' '.$src.' '.$dest) != 0) {
545-
print STDERR "ERROR executing [".$self->{PUT_CMD}." $src $dest]\n";
546-
}
545+
if (system ($self->{PUT_CMD}.' '.$src.' '.$dest) != 0) {
546+
print STDERR "ERROR executing [".$self->{PUT_CMD}." $src $dest]\n";
547+
}
547548
}
548549
elsif (($src ne $dest) &&
549550
(File::Spec->rel2abs($src) ne File::Spec->rel2abs($dest))) {
@@ -594,7 +595,14 @@ sub WaitForFileTimed ($)
594595
sub CreateProcess ($)
595596
{
596597
my $self = shift;
597-
my $process = new PerlACE::Process (@_);
598+
599+
my $process;
600+
if ($self->{config_name} eq 'NODEJS') {
601+
$process = new PerlACE::ProcessNodeJS(@_);
602+
} else {
603+
$process = new PerlACE::Process (@_);
604+
}
605+
598606
$process->Target($self);
599607
return $process;
600608
}

ACE/include/makeinclude/platform_clang_common.GNU

+5-3
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@ ifneq ($(CROSS_COMPILE),)
99
CXX = ${CROSS_COMPILE}clang++${CROSS_COMPILE_SUFFIX}
1010
AR = ${CROSS_COMPILE}ar${CROSS_COMPILE_SUFFIX}
1111
endif
12-
# Cross-linker requires this for linked in shared libs that depend
13-
# themselves on other shared libs (not directly linked in)
14-
LDFLAGS += -Wl,-rpath-link,$(ACE_ROOT)/lib
12+
ifneq ($(static_libs_only), 1)
13+
# Cross-linker requires this for linked in shared libs that depend
14+
# themselves on other shared libs (not directly linked in)
15+
LDFLAGS += -Wl,-rpath-link,$(ACE_ROOT)/lib
16+
endif
1517
ifneq (,$(HOST_ROOT))
1618
TAO_IDLFLAGS += -g $(HOST_ROOT)/bin/ace_gperf
1719
TAO_IDL = $(HOST_ROOT)/bin/tao_idl

ACE/include/makeinclude/platform_emscripten.GNU

+10-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ ACE_PLATFORM_CONFIG ?= config-emscripten.h
22
EXEEXT = .js
33

44
debug ?= 1
5-
optimize ?= 1
5+
optimize ?= 0
66
threads ?= 1
77
inline ?= 1
88
static_libs_only = 1
@@ -16,8 +16,16 @@ LD = emcc
1616

1717
ifeq ($(threads),1)
1818
FLAGS_C_CC += -pthread
19-
SOFLAGS += -pthread
19+
LDFLAGS += -pthread
2020
LIBS += -lrt
2121
endif
2222

23+
ifeq ($(debug),1)
24+
LDFLAGS += -sASSERTIONS=2
25+
endif
26+
27+
# TODO: Require choosing Filesystem model:
28+
# https://emscripten.org/docs/api_reference/Filesystem-API.html
29+
LDFLAGS += -sNODERAWFS=1
30+
2331
include $(ACE_ROOT)/include/makeinclude/platform_clang_common.GNU

ACE/tests/OS_Test.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -1208,7 +1208,7 @@ ace_ctype_test ()
12081208
++retval;
12091209
}
12101210

1211-
return 0;
1211+
return retval;
12121212
}
12131213

12141214
int

0 commit comments

Comments
 (0)