flutter-tizen / engine

The Flutter engine
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
6 stars 19 forks source link

How to load [abi:cxx11] symbol #253

Closed JSUYA closed 2 years ago

JSUYA commented 2 years ago

I am researching for rendering flutter-tizen in NUI (Tizen Natural User Interface (C#)) For this, I must use DALi(Tizen C++ UIFW) in engine(tizen renderer). Among the DALi APIs, there is an API that returns std::string and when I want to use this API, the link error occurred in engine build. ( ex: const std::string& Dali::Toolkit::ImageUrl::GetUrl() const)

tizen_renderer_ecore_wl2.cc:(.text._ZN7flutter21TizenRendererEcoreWl28SetupEGLEv+0x2d3): undefined reference to `Dali::Toolkit::ImageUrl::GetUrl() const

I found symbol for this API with the nm command. there is a [abi:cxx11] tag.

~/dev/os/engine/src ((HEAD detached at 4660f4a)) 16:08:11 $ nm -gDC tizen_tools/sysroot/x86/usr/lib/libdali2-toolkit.so | grep ImageUrl::GetUrl
0020fade T Dali::Toolkit::ImageUrl::GetUrl[abi:cxx11]() const

I was studying this and found that the engine compile script need __GLIBCXX_USE_CXX11_ABI = 1 //or 0 define. (https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html) I added it to build script and tried to build, but the problem was not resolved.

If you guys has any ideas for script modifications to use [abi:cxx11] api, please let me know.

(my tizen/Build.gn diff)

--- a/shell/platform/tizen/BUILD.gn
+++ b/shell/platform/tizen/BUILD.gn
@@ -21,6 +21,7 @@ source_set("flutter_engine") {
   lib_dirs = [ root_out_dir ]

   public_configs = [ ":embedder_rpath" ]
+  public_configs += [ "//build/config/compiler:rtti" ]

   deps = [ "//flutter/shell/platform/embedder:flutter_engine" ]
 }
@@ -52,6 +53,10 @@ config("rootstrap_include_dirs") {
     "$local_prefix/include/ecore-input-1",
     "$local_prefix/include/ecore-wayland-1",
     "$local_prefix/include/ecore-wl2-1",
+    "$local_prefix/include/dali",
+    "$local_prefix/include/dali-toolkit",
+    "$local_prefix/include/dali-adaptor",
+
     "$local_prefix/include/efl-1",
     "$local_prefix/include/efl-extension",
     "$local_prefix/include/eina-1",
@@ -144,6 +149,7 @@ template("embedder") {

     defines += invoker.defines
     defines += [ "FLUTTER_ENGINE_NO_PROTOTYPES" ]
+    defines += [ "_GLIBCXX_USE_CXX11_ABI=1"]

     configs +=
         [ "//flutter/shell/platform/common:desktop_library_implementation" ]
@@ -209,6 +215,9 @@ template("embedder") {
       ]

       libs += [
+        "dali2-core",
+        "dali2-adaptor",
+        "dali2-toolkit",
         "ecore_wl2",
         "tizen-extension-client",
       ]

compiler/build.gn

diff --git a/build/config/compiler/BUILD.gn b/build/config/compiler/BUILD.gn
index 9b5899e..3e5cc8e 100644
--- a/build/config/compiler/BUILD.gn
+++ b/build/config/compiler/BUILD.gn
@@ -631,17 +631,13 @@ if (is_win) {

   if (!use_xcode) {
     default_warning_flags += [
-      "-Wno-unused-but-set-parameter",
-      "-Wno-unused-but-set-variable",
       "-Wno-implicit-int-float-conversion",
       "-Wno-c99-designator",
       "-Wno-deprecated-copy",
       # Needed for compiling Skia with clang-12
-      "-Wno-psabi",
     ]
     if (!is_fuchsia) {
       default_warning_flags += [
-        "-Wno-non-c-typedef-for-linkage",
         "-Wno-range-loop-construct",
       ]
     }
@@ -678,6 +674,7 @@ config("chromium_code") {
     defines = [
       "__STDC_CONSTANT_MACROS",
       "__STDC_FORMAT_MACROS",
+      "_GLIBCXX_USE_CXX11_ABI=1"
     ]

     if (!using_sanitizer && (!is_linux || !is_clang)) {
@@ -718,6 +715,10 @@ config("no_chromium_code") {
 config("rtti") {
   if (is_win) {
     cflags_cc = [ "/GR" ]
+  } else {
+    rtti_flags = [ "-frtti" ]
+    cflags_cc = rtti_flags
+    cflags_objcc = rtti_flags
   }
 }
 config("no_rtti") {

tizen-tools

diff --git a/sysroot/build-rootfs.py b/sysroot/build-rootfs.py
index 06d6768..b11b2b1 100755
--- a/sysroot/build-rootfs.py
+++ b/sysroot/build-rootfs.py
@@ -62,6 +62,12 @@ unifiedPackages = [
     'edje-devel',
     'eet',
     'eet-devel',
+    'dali2',
+    'dali2-devel',
+    'dali2-adaptor',
+    'dali2-adaptor-devel',
+    'dali2-toolkit',
+    'dali2-toolkit-devel',
     'efl-devel',
     'efl-extension',
     'efl-extension-devel',
@@ -132,11 +138,11 @@ parser.add_argument(
 parser.add_argument(
     '-b', '--base-repo', metavar='URL', type=str,
     help='url to the base packages repository',
-    default='http://download.tizen.org/snapshots/tizen/5.5-base/latest/repos/standard/packages')
+    default='http://download.tizen.org/snapshots/tizen/6.5-base/latest/repos/standard/packages')
 parser.add_argument(
     '-u', '--unified-repo', metavar='URL', type=str,
     help='url to the unified packages repository',
-    default='http://download.tizen.org/snapshots/tizen/5.5-unified/latest/repos/standard/packages')
+    default='http://download.tizen.org/snapshots/tizen/6.5-unified/latest/repos/standard/packages')
 args = parser.parse_args()

 if not args.output:

Sample Dali code


   #include "dali-toolkit/public-api/image-loader/image-url.h"
   #include "dali-toolkit/dali-toolkit.h"
   #include "dali/devel-api/adaptor-framework/native-image-source-queue.h"
   #include "tbm_surface.h"
   #include "tbm_surface_queue.h"
    ...
    tbm_surface_queue_h mTbmQueue = nullptr;
    Dali::NativeImageSourceQueuePtr mNativeImageQueue = nullptr;
    Dali::Texture mNativeTexture;
    ...
    mTbmQueue = tbm_surface_queue_create(3 , 500, 500, TBM_FORMAT_ARGB8888, 0);
    mNativeImageQueue = Dali::NativeImageSourceQueue::New(mTbmQueue);
    mNativeTexture = Dali::Texture::New(*mNativeImageQueue);
    Dali::Toolkit::ImageUrl imageUrl = Dali::Toolkit::ImageUrl::New(mNativeTexture);
    std::string url = imageUrl.GetUrl();  //<< Error

    FT_LOG(Error) << "CJS URL : " << url;
swift-kim commented 2 years ago

I couldn't find a way to make this work without fixing the dependent libraries. I think libdali2 must be recompiled with correct options.

bbrto21 commented 2 years ago

Both dali and flutter-tizen use -std=c++17 and use _GLIBCXX_USE_CXX11_ABI with default value. so I couldn't understand this issue clearly.

After looking at it for a while, I think it's because custom libcxx is used when building engine. so, it seems that different from used in Tizen is being referenced at build time.

see here, you can check the detailed build configuration.

use_flutter_cxx = is_clang && (is_linux || is_android || is_mac)
if (use_flutter_cxx) {
  _native_compiler_configs += [
    "//third_party/libcxxabi:libcxxabi_config",
    "//third_party/libcxx:libcxx_config",
  ]
}

So... It's my guess, but if any C++ library interface provided by Tizen includes a libcxx's interface, it looks like it won't be available In our current build configuration at all.

bbrto21 commented 2 years ago
use_flutter_cxx = is_clang && (is_linux || is_android || is_mac)

I wonder if this is the result of our intention. @flutter-tizen/maintainers Does anyone know?

swift-kim commented 2 years ago

@bbrto21 libc++ is statically linked into the engine and embedder to avoid any subtle compatibility issue. For example, the PR https://github.com/flutter-tizen/engine/pull/205 already assumes this fact.

bbrto21 commented 2 years ago

@JSUYA I modified the custom configuration of the build root a bit, and I succeeded in linking the Dali api. also, I succeeded in creating the egl surface using Dali::NativeImageSourceQueue as you guided and I set the imageUrl to imageView on FlutterNUIApplcation I made, but It doesn't seem to work. Could you explain your idea in more detail? I don't have any experience with Dali.

bbrto21 commented 2 years ago

I want to use TizenFX API Level 9. how should I change the project configuration? I tried several things, but it seems that API Level 4 is still selected.

swift-kim commented 2 years ago

Do you mean a .NET app?

  1. Set the api-version attribute of the ui-application element in tizen-manifest.xml to 9.
  2. Change the target framework moniker to tizen90 in Runner.csproj.
bbrto21 commented 2 years ago
  • Set the api-version attribute of the ui-application element in tizen-manifest.xml to 9.
  • Change the target framework moniker to tizen90 in Runner.csproj

I tried following the instructions above, but it didn't work. @WonyoungChoi Could you possibly help on this?

bbrto21 commented 2 years ago

@WonyoungChoi Could you possibly help on this?

I got the answer from him that the documentation is wrong. the API I was trying to use was not included in the latest release of TizenFX API Level 9.

bbrto21 commented 2 years ago

@JSUYA Here is a buildable changes with dali2 dependency, before using this patch, you must apply for_dali.patch in this changes to the build root. and you must change the FlutterApplication base class from CoreUIApplication to NUIApplication This change is workaround and some headers had to be added to the existing implementation because libcxx implementations are different

bbrto21 commented 2 years ago

related issue https://github.com/flutter-tizen/flutter-tizen/issues/351