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

FEXInterpreter: Support portable installs #3929

Merged
merged 1 commit into from
Sep 2, 2024

Conversation

Sonicadvance1
Copy link
Member

A couple things to note here.

This expects multiple environment variables to be set

  • FEX_PORTABLE=1
  • FEX_THUNKHOSTLIBS=<Local install path for thunks>
  • FEX_THUNKHOSTLIBS32=<Local install path for thunks>
  • FEX_THUNKGUESTLIBS=<Local install path for thunks>
  • FEX_THUNKGUESTLIBS32=<Local install path for thunks>

Some optional environment variables that can be set

  • FEX_APP_CONFIG_LOCATION
    • With FEX_PORTABLE set, this will default to a path at <FEXInterpreter>/fex-emu/
    • This overrides the default $HOME behaviour
    • This path is used by the $HOME/.fex-emu/Config.json and $HOME/.fex-emu/AppConfig/<Files>.json
  • FEX_APP_DATA_LOCATION
    • With FEX_PORTABLE set, this will default to a path at <FEXInterpreter>/fex-emu/
    • This overrides the default $HOME behaviour
    • This path is used by the $HOME/.fex-emu/Telemetry/ and various other data bits like IR cache, code cache and probably in the future more things

This also disables FEX trying to use the binfmt_misc handler even if it is installed, so it stays disjoint from the system install.
It also disables the three global config layers since it doesn't make sense in this config.

This isn't the default and shouldn't be expected as the default use case. It also likely breaks namespaces and chroots so shouldn't be used in those cases most of the time.

@Sonicadvance1 Sonicadvance1 force-pushed the portable branch 2 times, most recently from 3ca853e to 897bace Compare August 23, 2024 23:17
@Sonicadvance1 Sonicadvance1 marked this pull request as ready for review August 29, 2024 14:33
@Sonicadvance1
Copy link
Member Author

This is working as intended and can now be reviewed/merged.

FEXCore/Scripts/config_generator.py Outdated Show resolved Hide resolved
Source/Common/Config.cpp Outdated Show resolved Hide resolved
Source/Common/Config.cpp Outdated Show resolved Hide resolved
Source/Common/Config.cpp Show resolved Hide resolved
Source/Tools/FEXLoader/FEXLoader.cpp Show resolved Hide resolved
Source/Tools/FEXLoader/FEXLoader.cpp Outdated Show resolved Hide resolved
Source/Tools/FEXLoader/FEXLoader.cpp Outdated Show resolved Hide resolved
Source/Common/Config.h Outdated Show resolved Hide resolved
Source/Tools/FEXLoader/FEXLoader.cpp Outdated Show resolved Hide resolved
Source/Tools/FEXLoader/FEXLoader.cpp Outdated Show resolved Hide resolved
Copy link
Member

@neobrain neobrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking much better, thanks!

PR title still says "portable-ish". What's "-ish" about it?

Source/Tools/FEXLoader/FEXLoader.cpp Outdated Show resolved Hide resolved
* @return true if the binfmt_misc handlers are installed and being used
*/
bool QueryInterpreterInstalled(const bool ExecutedWithFD, const FEX::Config::PortableInformation& Portable) {
// We know the FEX interpreter is installed through a couple paths.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unclear what this line is trying to say. Are we checking any paths here to figure out if the FEX interpreter is installed? Which paths? None of the bullet points after mention any paths.

On third read, it seems you're using "path" in a figurative way, which is confusing in code that also does filesystem operations... Is the intent here that we have multiple methods of checking whether FEXInterpreter is installed?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, if the paths exist, or if ExecutedWithFD then we know that the Linux kernel binfmt_misc interpreter is installed. /proc doesn't need to be mounted inside of a chroot for example, so those two paths checks could not exist, but binfmt_misc interpreter is still installed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is probably clearer:

  // Check if FEX's binfmt_misc handlers are both installed.
  // The explicit check can be omitted if FEX was executed from an FD,
  // since this only happens if the kernel launched FEX through binfmt_misc

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, scratch that, let me revisit this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess my proposal captures the essence of it, though it would be nice if the nuance of /proc possibly not being visible could be factored in as well. Then again /proc is typically mounted in a chroot, so this may be too much of an edge case to bother going into the detail.

Anyway, seems good enough.

Source/Tools/FEXLoader/FEXLoader.cpp Outdated Show resolved Hide resolved
Source/Tools/FEXLoader/FEXLoader.cpp Outdated Show resolved Hide resolved
FEXCore/Scripts/config_generator.py Outdated Show resolved Hide resolved
Source/Common/Config.cpp Show resolved Hide resolved
Source/Common/Config.cpp Outdated Show resolved Hide resolved
@Sonicadvance1 Sonicadvance1 changed the title FEXInterpreter: Support portable-ish installs FEXInterpreter: Support portable installs Sep 2, 2024
@Sonicadvance1 Sonicadvance1 force-pushed the portable branch 3 times, most recently from 509ae13 to 5a5a5ec Compare September 2, 2024 15:00
@neobrain
Copy link
Member

neobrain commented Sep 2, 2024

PR title doesn't say "portable-ish" anymore, why did it say so before?

@Sonicadvance1
Copy link
Member Author

PR title doesn't say "portable-ish" anymore, why did it say so before?

Oh right, It's effectively portable as long as you don't care about the quirks that can occur by not having binfmt_misc handlers installed. Which is why I said "portable-ish" before, but it is a non-issue for most things we care about.

Copy link
Member

@neobrain neobrain left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, It's effectively portable as long as you don't care about the quirks that can occur by not having binfmt_misc handlers installed. Which is why I said "portable-ish" before, but it is a non-issue for most things we care about.

Ah, that makes sense. Sounds fine to advertise it without the "-ish" qualifier indeed then, since it's more of a side effect of binfmt_misc not being used than a limitation of portable mode.

@Sonicadvance1 Sonicadvance1 merged commit 9336e35 into FEX-Emu:main Sep 2, 2024
12 checks passed
@Sonicadvance1 Sonicadvance1 deleted the portable branch September 2, 2024 17:13
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