Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fixes for Cross-Compilation Issues #272

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Conversation

Losses
Copy link
Contributor

@Losses Losses commented Sep 16, 2024

This pull request includes two key modifications to address potential issues in the cross-compilation process:

1. Configuration Updates in CMakeLists.txt

Introducing necessary configurations in CMakeLists.txt to ensure the correct discovery and linking of package directories during cross-compilation. The changes include:

  • Finding and Linking Required Packages:
    • Fontconfig
    • X11 with xkbcommon
    • OpenGL with EGL
  • Utilizing pkg-config to locate Wayland libraries:
    • wayland-egl
    • wayland-client
    • wayland-cursor
  • Linking Dependencies: These dependencies are linked to the flutter target.
  • Including Necessary Directories: The required directories for these dependencies are included.

Problem Addressed:

Previously, the build system struggled to correctly locate package directories during cross-compilation, leading to build failures. These changes ensure that the necessary packages and libraries are correctly found and linked, thereby facilitating a successful build process.

2. Fix for Diverse Compiler Invocation Commands

Resolving issues related to cross-platform compilation on certain operating systems, such as NixOS, by supporting diverse compiler invocation commands.

Details:

  • Issue: The current implementation assumed specific commands for invoking clang and clang++. However, different operating systems might use different commands. For instance, on NixOS, the commands are aarch64-unknown-linux-gnu-clang and aarch64-unknown-linux-gnu-clang++.
  • Solution: The commit respects the original environment variable settings, allowing users to specify the binary names provided by their distribution. This flexibility improves support for various operating systems and compilation environments.

Problem Addressed:

Certain operating systems were unable to complete cross-platform compilation due to hardcoded compiler invocation commands. By allowing customizable compiler commands, this fix enhances the project's cross-platform compatibility.

Potentially related to #159, since an incorrect compiler could trigger the same error.

…ing diverse compiler invocation commands

This commit addresses the issue where certain operating systems (e.g., NixOS) were unable to complete cross-platform compilation. The current implementation assumes that all clang and clang++ invocations are done using specific commands. However, in reality, the invocation of these compilers can vary. For example, on NixOS, the compiler commands are actually: `aarch64-unknown-linux-gnu-clang` and `aarch64-unknown-linux-gnu-clang++`.

To resolve this, we should respect the original environment variable settings and allow users to determine the binary names provided by their distribution. This adjustment improves our support for different operating systems and compilation environments, enhancing the cross-platform compatibility of the project.
This commit added necessary configurations to `CMakeLists.txt` to ensure the correct discovery of package directories during cross-compilation. This includes:

- Finding and linking required packages: Fontconfig, X11 with xkbcommon, and OpenGL with EGL.
- Utilizing pkg-config to locate Wayland libraries: wayland-egl, wayland-client, and wayland-cursor.
- Linking these dependencies to the flutter target.
- Including the necessary directories for these dependencies.

These changes address the issue where the build system could not correctly locate package directories during cross-compilation, thereby ensuring a successful build process.
@HidenoriMatsubayashi
Copy link
Collaborator

HidenoriMatsubayashi commented Sep 16, 2024

Thank you for sending this PR.

Introducing necessary configurations in CMakeLists.txt to ensure the correct discovery and linking of package directories during cross-compilation. The changes include:

X11, Wayland, and DRM are independent of each other, and aside from common dependency libraries, they are not required for building an application. For example, in the case of X11, the Wayland libraries are unnecessary.

See also: https://github.com/sony/flutter-elinux/wiki/flutter-elinux-install#3-installing-dependent-libraries-for-runtime-binary-flutter-app

If you want to proceed with this change, you will need to implement code that checks for only the necessary components depending on the type of backend.

  1. Fix for Diverse Compiler Invocation Commands

This looks good to me.

@Losses
Copy link
Contributor Author

Losses commented Sep 16, 2024

It seems we need to find a way for CMake to know which dependencies it requires. This is a bit complex to me, so please give me some time to think about this issue.

@HidenoriMatsubayashi
Copy link
Collaborator

I suppose FLUTTER_TARGET_BACKEND_TYPE var can be used to identify which dependencies are needed.

https://github.com/sony/flutter-elinux/blob/main/templates/app/CMakeLists.txt.tmpl#L28

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants