lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Hi,

I've updated the test patch slightly--some additional small portability tweaks for Windows and FreeBSD support.

I have also attached a small patch for fixing up the LUAI_MAXCALLS default for Windows.

Finally, I have attached a patch to allow building with C++ but loading the test modules or linking with C code without having problems with the C++ name mangling of exported symbols.  This patch will explicitly retain C linkage for exported symbols, while internal (non-exported) symbols can retain C++ linkage and name mangling.

Tested on Windows 11, FreeBSD 13.2 and Linux (Ubuntu 22.10)
Tested configuration: C (static libs), C (shared libs and test modules), C++ (shared libs and test modules)

Kind regards,
Roger

> -----Original Message-----
> From: Roger Leigh <rleigh@codelibre.net>
> Sent: Sunday, April 16, 2023 9:33 AM
> To: Lua mailing list <lua-l@lists.lua.org>
> Subject: [PATCH] Testing support for C++, without loader support, and for
> Windows
> 
> Hi,
> 
> Over the last few weeks, I've been attempting to get the Lua testsuite to work
> in various configurations, including when built with a C++ compiler and/or
> shared or static, and/or on Windows.  Patch is attached.  The original changes
> are here: https://gitlab.com/codelibre/lua/lua-cmake/-/commits/lua-cmake-
> 5.4?ref_type=heads
> 
> In order to adapt to different build configurations, several environment
> variables may be used to override the default behaviour:
> 
> LUA_LANGUAGE=C|CXX -- Language used when building
> LUA_USE_READLINE=0|1 -- If readline was used (since it affects interactivity
> tests)
> LUA_LIBRARY_LOADER=0|1 -- If library loading support is available (attrib.lua
> tests won't work if disabled) LUA_TEST_DIR= -- Directory path for Lua test
> files (for out-of-source builds where the location isn't known) LUA_PATH= --
> override as needed to load test files with require LUA_CPATH= -- override as
> needed to load test modules with require
> 
> For Windows, most of the tests in main.lua needed an alternative command
> to use with popen or system, so they will work with the cmd.exe shell instead
> of Bourne shell.  Mostly different quoting rules.  There was one I couldn't get
> working due to the difficulty passing a literal space, which is commented in
> the patch.  I also adapted the time tests to work with the supported time
> ranges on Windows.
> 
> An additional compatibility tweak is needed identified during testing: On
> Windows the gsub recursion test fails.  Windows needs
> LUAI_MAXCCALLS=150, not the 200 default.  The default in llimits.h might
> need to be conditional so that it's 150 on Windows, 200 otherwise.
> 
> I'm sure there are many additional improvements which could be made on
> top of this, but I hope this is a useful foundation for enabling proper testing
> of build configurations other than C on Unix with module loading enabled.
> 
> Kind regards,
> Roger

Attachment: 0001-tests-Adapt-to-run-on-Windows-and-FreeBSD.patch
Description: 0001-tests-Adapt-to-run-on-Windows-and-FreeBSD.patch

Attachment: 0002-Set-LUAI_MAXCCALLS-to-150-on-Windows.patch
Description: 0002-Set-LUAI_MAXCCALLS-to-150-on-Windows.patch

Attachment: 0003-C++-symbol-export-no-name-mangling.patch
Description: 0003-C++-symbol-export-no-name-mangling.patch