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

broken cross compile work around added #129

Merged
merged 3 commits into from Sep 2, 2022

Conversation

Taha-Firoz
Copy link
Contributor

@Taha-Firoz Taha-Firoz commented Sep 1, 2022

Cross compile from x86 to arm is broken atleast for me, every since CMAKE_SYSROOT was passed directly the try_compile uses an arm compiler instead of a cross compiler which makes it fail everytime.

I have tried creating new projects and this is a reproducible error, compile any new flutter-elinux project with:

flutter-elinux build elinux -v --target-backend-type=gbm --target-compiler-triple=aarch64-linux-gnu  --target-arch=arm64  --target-sysroot=/home/me/rsc/arm64-sysroot --system-include-directories=/usr/aarch64-linux-gnu/include/c++/9/aarch64-linux-gnu

You will get this error:

Run Build Command(s):/home/me/rsc/arm64-sysroot/usr/bin/make cmTC_b676e/fast && /lib/ld-linux-aarch64.so.1: No such file or directory

This is because when CMAKE_SYSROOT is set before the project statement cmakes try_compile uses make from the arm64 sysroot which won't run on x86. My work around is simple just so I don't have to revert everything done in #105 set a temporary variable as CMAKE_SYSROOT, unset CMAKE_SYSROOT, let try_compile succeed then set CMAKE_SYSROOT to temp variable and set CMAKE_FIND_ROOT_PATH.

This is only a work around but it finally works, also you need to update the documentation that specifying --target-compiler-triple=aarch64-linux-gnu for regular x86-arm is required now, the previous versions would add this flag automatically but this current version no longer adds it automatically and thus builds fail.

@Taha-Firoz
Copy link
Contributor Author

This should close #128

@HidenoriMatsubayashi
Copy link
Collaborator

@HidenoriMatsubayashi
Copy link
Collaborator

And also, please add Developer Certificate of Origin (DCO).

@Taha-Firoz
Copy link
Contributor Author

I followed the CONTRIBUTING guide but I don't know how to add a DCO, it says I should just add this to my commit message
Signed-off-by: Taha Firoz mtahafiroz@gmail.com

🤷‍♂️

@andreadaoud
Copy link
Contributor

andreadaoud commented Sep 2, 2022

I disagree with this change. In https://cmake.org/cmake/help/latest/variable/CMAKE_SYSROOT.html , it says that this variable can only be set with toolchain file (or, be passed in commandline arguments).

What I recommend you to try, is to put this line: set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) before project. In this way cmake probably won't try to find the make tool in your sysroot. Please tell me if this works.

@Taha-Firoz
Copy link
Contributor Author

Okay this works, I'm also adding an update in the wiki because now specifying compiler triple is also required now.

@Taha-Firoz
Copy link
Contributor Author

Taha-Firoz commented Sep 2, 2022

I disagree with this change.

Of course I disagree with it too but I don't know too much about cmake and I just needed my code to compile which is why I made that work around. Your proposed solution fixes it properly, I also think maybe we can add a new parameter to flutter-elinux as an optional string to pass any arbitrary flags to cmake.

@HidenoriMatsubayashi
Copy link
Collaborator

Is the PR ready to be reviewed/merged or still a draft?

@Taha-Firoz Taha-Firoz marked this pull request as ready for review September 2, 2022 13:11
@Taha-Firoz
Copy link
Contributor Author

Ready for review

@HidenoriMatsubayashi HidenoriMatsubayashi merged commit 56d0513 into sony:main Sep 2, 2022
@HidenoriMatsubayashi
Copy link
Collaborator

Thanks a lot.

@Taha-Firoz
Copy link
Contributor Author

You forgot to add the wiki entries

@HidenoriMatsubayashi
Copy link
Collaborator

Updated.

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.

None yet

3 participants