vegardit / haxe-concurrent

A haxelib for basic platform-agnostic concurrency support
https://vegardit.github.io/haxe-concurrent/
Apache License 2.0
82 stars 14 forks source link

CPP abstract class error when building with Lime #22

Closed EliteMasterEric closed 1 year ago

EliteMasterEric commented 2 years ago

This issue is similar to that of #21, however after revisiting the issue recently and finding that the Travix tests function properly, I decided to perform a more thorough investigation.

As a result, I discovered the issue and have developed a minimal reproduction and provided additional logs.

The core issue is, I believe, with the lime framework, whose purpose is to provide additional utilities for cross-platform development, such as common interfaces for functionality like rendering. This library supercedes the build tools provided by Haxe, and some of the command line arguments it adds may be causing these build problems.

I was able to reproduce my problems with the following steps:

  1. Install Lime via Haxelib (haxelib install lime)
  2. Create a minimal Lime sample project (lime create HelloWorld)
  3. Open project.xml and add the haxelib (<haxelib name="haxe-concurrent" />)
  4. Add code to Main.hx to use the library (I simply added code which instantiates a RLock and nothing else)
  5. Attempt to build the project (lime build windows)

The build fails with an error relating to methods of an abstract class. I am not an expert in C++ compilation but my theory is that the issue arises from one of the build flags enforced by Lime.

I have uploaded the project where I reproduced the issue to GitHub Below are the full logs from the build process:

Executing task: lime build windows --connect 6001 

C:/HaxeToolkit/Haxe425/haxe/lib/haxe-concurrent/4,0,0/src/hx/concurrent/internal/Macros.hx:35: [INFO] Setting compiler define 'threads'.
Creating D:/Programming/Haxe/Lime-HelloWorld/Export/windows/obj/obj/msvc1964-nc/__pch/haxe/hxcpp.pch...
hxcpp.cpp

Compiling group: haxe
cl.exe -Iinclude -nologo /WX- /fp:precise -DHX_WINDOWS -GR -O2(optim-std) -Zi(debug) -FdD:\Programming\Haxe\Lime-HelloWorld\Export\windows\obj\obj/msvc1964-nc/vc.pdb(debug) -Od(debug) -O2(release) -Os(optim-size) -FS -Oy- -c -EHs -GS- -IC:/HaxeToolkit/Haxe425/haxe/lib/hxcpp/4,2,1/include -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS(haxe) -DHX_SMART_STRINGS(haxe) -DHXCPP_API_LEVEL=400(haxe) -D_CRT_SECURE_NO_DEPRECATE -D_ALLOW_MSC_VER_MISMATCH -D_ALLOW_ITERATOR_DEBUG_LEVEL_MISMATCH -DHX_WIN_MAIN(main) -wd4996 ... tags=[haxe,static]
 - src/lime/app/_Event_lime_ui_Window_Void.cpp  [haxe,release]
 - src/lime/media/openal/_ALAuxiliaryEffectSlot/ALAuxiliaryEffectSlot_Impl_.cpp
 - src/lime/system/SensorType.cpp
 - src/sys/io/_Process/Stdout.cpp
 - src/lime/_internal/backend/native/TextEventInfo.cpp
 - src/lime/graphics/cairo/_CairoFontOptions/CairoFontOptions_Impl_.cpp
 - src/lime/math/Rectangle.cpp  [haxe,release]
 - src/sys/FileSystem.cpp 
 - src/lime/graphics/opengl/ext/EXT_multi_draw_arrays.cpp 
 - src/lime/utils/_Int32Array/Int32Array_Impl_.cpp 
 - src/lime/media/openal/ALC.cpp  [haxe,release]
 - src/haxe/ValueException.cpp 
 - src/lime/media/openal/_ALContext/ALContext_Impl_.cpp
 - src/lime/graphics/opengl/ext/EXT_debug_marker.cpp
 - src/lime/system/_ThreadPool/ThreadPoolMessage.cpp
 - src/lime/app/_Future/FutureWork.cpp  [haxe,release]
 - src/lime/_internal/backend/native/WindowEventInfo.cpp 
 - src/lime/graphics/opengl/ext/OES_vertex_half_float.cpp
 - src/haxe/StackItem.cpp
 - src/lime/app/Promise.cpp  [haxe,release]
 - src/lime/_internal/backend/native/MouseEventInfo.cpp 
 - src/lime/graphics/opengl/ext/NV_fence.cpp 
 - src/lime/_internal/macros/AssetsMacro.cpp
 - src/lime/graphics/opengl/ext/EXT_texture_format_BGRA8888.cpp 
 - src/haxe/crypto/BaseCode.cpp 
 - src/lime/graphics/opengl/ext/OES_surfaceless_context.cpp 
 - src/lime/_internal/format/LZMA.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/APPLE_texture_format_BGRA8888.cpp 
 - src/lime/graphics/cairo/_CairoFontFace/CairoFontFace_Impl_.cpp 
 - src/lime/graphics/opengl/ext/QCOM_binning_control.cpp 
 - src/lime/graphics/opengl/_GLBuffer/GLBuffer_Impl_.cpp 
 - src/lime/app/_Event_lime_graphics_RenderContext_Void.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/OES_depth_texture.cpp 
 - src/lime/graphics/opengl/ext/OES_standard_derivatives.cpp 
 - src/__boot__.cpp 
 - src/lime/ui/_GamepadAxis/GamepadAxis_Impl_.cpp
 - src/lime/system/_ThreadPool/ThreadPoolMessageType.cpp 
 - src/lime/graphics/opengl/ext/EXT_color_buffer_float.cpp 
 - src/lime/graphics/opengl/ext/DMP_shader_binary.cpp 
 - src/Std.cpp 
 - src/sys/thread/_Thread/HaxeThread.cpp 
 - src/lime/net/curl/CURLMultiMessage.cpp 
 - src/lime/graphics/opengl/ext/EXT_shader_texture_lod.cpp 
 - src/lime/graphics/Image.cpp  [haxe,release]
 - src/lime/utils/Preloader.cpp  [haxe,release]
 - src/lime/graphics/_OpenGLES3RenderContext/OpenGLES3RenderContext_Impl_.cpp 
 - src/lime/media/WebAudioContext.cpp 
 - src/lime/graphics/opengl/ext/APPLE_texture_max_level.cpp 
 - src/lime/graphics/_WebGL2RenderContext/WebGL2RenderContext_Impl_.cpp 
 - src/haxe/NativeStackTrace.cpp 
 - src/sys/thread/_EventLoop/RegularEvent.cpp 
 - src/lime/utils/AssetManifest.cpp  [haxe,release]
 - src/lime/text/GlyphMetrics.cpp  [haxe,release]
 - src/ValueType.cpp 
 - src/lime/media/FlashAudioContext.cpp 
 - src/lime/math/_BGRA/BGRA_Impl_.cpp 
 - src/lime/graphics/opengl/ext/QCOM_writeonly_rendering.cpp 
 - src/lime/_internal/backend/native/NativeCFFI.cpp  [haxe,release]
 - src/lime/math/Vector4.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/OES_mapbuffer.cpp 
 - src/lime/_internal/graphics/StackBlur.cpp 
 - src/haxe/Exception.cpp 
 - src/lime/graphics/opengl/ext/VIV_shader_binary.cpp 
 - src/lime/_internal/format/BMP.cpp  [haxe,release]
 - src/lime/_internal/backend/native/RenderEventInfo.cpp 
 - src/haxe/io/Input.cpp 
 - src/lime/system/JNIStaticField.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/OES_compressed_ETC1_RGB8_texture.cpp 
 - src/lime/system/_CFFIPointer/CFFIPointer_Impl_.cpp 
 - src/lime/media/vorbis/VorbisFile.cpp 
 - src/lime/media/openal/AL.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/OES_depth32.cpp 
 - src/lime/media/openal/_ALEffect/ALEffect_Impl_.cpp 
 - src/lime/graphics/opengl/ext/OES_texture_half_float_linear.cpp 
 - src/lime/graphics/opengl/ext/EXT_debug_label.cpp 
 - src/lime/utils/_Int8Array/Int8Array_Impl_.cpp 
 - src/lime/app/_Event_Int_lime_ui_JoystickHatPosition_Void.cpp  [haxe,release]
 - src/lime/ui/_ScanCode/ScanCode_Impl_.cpp 
 - src/lime/media/openal/_ALFilter/ALFilter_Impl_.cpp 
 - src/lime/utils/_Assets/LibrarySymbol.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/EXT_texture_filter_anisotropic.cpp 
 - src/Date.cpp 
 - src/lime/media/OpenALAudioContext.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/ANGLE_texture_compression_dxt5.cpp 
 - src/lime/app/_Event_lime_ui_GamepadButton_Void.cpp  [haxe,release]
 - src/lime/app/_Event_lime_ui_GamepadAxis_Float_Void.cpp  [haxe,release]
 - src/lime/system/JNIMethod.cpp  [haxe,release]
 - src/lime/media/AudioManager.cpp  [haxe,release]
 - src/haxe/io/Eof.cpp 
 - src/lime/graphics/opengl/ext/OES_EGL_image_external.cpp 
 - src/lime/_internal/format/PNG.cpp  [haxe,release]
 - src/lime/media/openal/_ALDevice/ALDevice_Impl_.cpp 
 - src/lime/utils/_Bytes/Bytes_Impl_.cpp 
 - src/lime/ui/Gamepad.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/EXT_multisampled_render_to_texture.cpp 
 - src/lime/graphics/opengl/ext/EXT_texture_type_2_10_10_10_REV.cpp 
 - src/lime/net/_HTTPRequest_lime_graphics_Image.cpp  [haxe,release]
 - src/lime/graphics/opengl/ext/ARM_rgba8.cpp 
 - src/haxe/ds/_List/ListNode.cpp 
 - src/haxe/Unserializer.cpp 
 - src/lime/graphics/RenderContext.cpp 
 - src/lime/utils/_UInt32Array/UInt32Array_Impl_.cpp 
 - src/lime/utils/Log.cpp  [haxe,release]
 - src/haxe/ds/List.cpp 
 - src/hx/concurrent/lock/RLock.cpp 
 - src/lime/app/_Event_Float_Float_lime_ui_MouseButton_Void.cpp  [haxe,release]
Error: RLock.cpp
./src/hx/concurrent/lock/RLock.cpp(45): error C2259: 'hx::concurrent::lock::RLock_obj': cannot instantiate abstract class
include\hx/concurrent/lock/RLock.h(21): note: see declaration of 'hx::concurrent::lock::RLock_obj'
./src/hx/concurrent/lock/RLock.cpp(45): note: due to following members:
./src/hx/concurrent/lock/RLock.cpp(45): note: 'bool hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire(int)': is abstract
include\hx/concurrent/lock/AbstractAcquirable.h(48): note: see declaration of 'hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire'
./src/hx/concurrent/lock/RLock.cpp(45): error C2259: 'hx::concurrent::lock::RLock_obj': cannot instantiate abstract class
include\hx/concurrent/lock/RLock.h(21): note: see declaration of 'hx::concurrent::lock::RLock_obj'
./src/hx/concurrent/lock/RLock.cpp(45): note: due to following members:
./src/hx/concurrent/lock/RLock.cpp(45): note: 'bool hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire(int)': is abstract
include\hx/concurrent/lock/AbstractAcquirable.h(48): note: see declaration of 'hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire'
./src/hx/concurrent/lock/RLock.cpp(51): error C2259: 'hx::concurrent::lock::RLock_obj': cannot instantiate abstract class
include\hx/concurrent/lock/RLock.h(21): note: see declaration of 'hx::concurrent::lock::RLock_obj'
./src/hx/concurrent/lock/RLock.cpp(51): note: due to following members:
./src/hx/concurrent/lock/RLock.cpp(51): note: 'bool hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire(int)': is abstract
include\hx/concurrent/lock/AbstractAcquirable.h(48): note: see declaration of 'hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire'
./src/hx/concurrent/lock/RLock.cpp(189): error C2259: 'hx::concurrent::lock::RLock_obj': cannot instantiate abstract class
include\hx/concurrent/lock/RLock.h(21): note: see declaration of 'hx::concurrent::lock::RLock_obj'
./src/hx/concurrent/lock/RLock.cpp(189): note: due to following members:
./src/hx/concurrent/lock/RLock.cpp(189): note: 'bool hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire(int)': is abstract
include\hx/concurrent/lock/AbstractAcquirable.h(48): note: see declaration of 'hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire'
./src/hx/concurrent/lock/RLock.cpp(334): error C2259: 'hx::concurrent::lock::RLock_obj': cannot instantiate abstract class
include\hx/concurrent/lock/RLock.h(21): note: see declaration of 'hx::concurrent::lock::RLock_obj'
./src/hx/concurrent/lock/RLock.cpp(334): note: due to following members:
./src/hx/concurrent/lock/RLock.cpp(334): note: 'bool hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire(int)': is abstract
include\hx/concurrent/lock/AbstractAcquirable.h(48): note: see declaration of 'hx::concurrent::lock::AbstractAcquirable_obj::tryAcquire'

 *  The terminal process "C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -Command lime build windows --connect 6001" terminated with exit code: 1. 
 *  Terminal will be reused by tasks, press any key to close it. 
sebthom commented 2 years ago

Does it compile if you enable full DCE?

<haxeflag name="-dce" value="full" />
EliteMasterEric commented 2 years ago

Compilation does succeed if DCE is set to full.

Since my project does utilize reflection, I will have to find a way to enable DCE on only this library (unless another fix is available that can be implemented on this repo).

sebthom commented 2 years ago

I don't think there is anything we can change here. I suspect that hxcpp is somehow broken and emits wrong C++ code for classes that extend abstract classes. So I guess for a fix you would need to report this issue to the hxcpp team.

You can try to use version 3.0.2 to see if it compiles, this version does not yet use abstract classes.

EliteMasterEric commented 2 years ago

The project successfully builds when reverting to haxe-concurrent version 3.0.2. Since the only functional change is the addition of SynchronizedMap, this is the solution I will be moving forward with.

As you suggested, I reported the issue at HaxeFoundation/haxe#10861

EDIT: Switching to 3.0.2, build works now in my main project. Will leave this issue open until the latest available version of this library works.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. If the issue is still valid, please add a respective comment to prevent this issue from being closed automatically. Thank you for your contributions.