diff options
| author | ptitSeb <sebastien.chev@gmail.com> | 2022-03-27 12:33:02 +0200 |
|---|---|---|
| committer | ptitSeb <sebastien.chev@gmail.com> | 2022-03-27 12:33:02 +0200 |
| commit | de2b3afa17112423551c757d153df8c73d2e275e (patch) | |
| tree | cd50771cc0436ac8d2c783b7821143a4ef35b392 /src | |
| parent | 46ab4b5b712ff42198218cc335028c3615346f7a (diff) | |
| download | box64-de2b3afa17112423551c757d153df8c73d2e275e.tar.gz box64-de2b3afa17112423551c757d153df8c73d2e275e.zip | |
Added BOX64_PREFER_EMULATED handling and special case for pressure-vessel to use it
Diffstat (limited to 'src')
| -rwxr-xr-x | src/include/debug.h | 1 | ||||
| -rwxr-xr-x | src/librarian/library.c | 23 | ||||
| -rwxr-xr-x | src/library_list.h | 1 | ||||
| -rwxr-xr-x | src/main.c | 16 | ||||
| -rw-r--r-- | src/steam.c | 24 |
5 files changed, 52 insertions, 13 deletions
diff --git a/src/include/debug.h b/src/include/debug.h index 7fb8d558..b5f08599 100755 --- a/src/include/debug.h +++ b/src/include/debug.h @@ -34,6 +34,7 @@ extern char* trace_func; extern int allow_missing_libs; extern int box64_mapclean; extern int box64_prefer_wrapped; +extern int box64_prefer_emulated; extern int box64_steam; extern int box64_wine; extern int box64_nopulse; // disabling the use of wrapped pulseaudio diff --git a/src/librarian/library.c b/src/librarian/library.c index 32a58311..208ca4fe 100755 --- a/src/librarian/library.c +++ b/src/librarian/library.c @@ -310,6 +310,24 @@ static void initEmulatedLib(const char* path, library_t *lib, box64context_t* co } } +static const char* essential_libs[] = { + "libc.so.6", "libpthread.so.0", "librt.so.1", "libGL.so.1", "libGL.so", "libX11.so.6", + "libasound.so.2", "libdl.so.2", "libm.so.6", + "libXxf86vm.so.1", "libXinerama.so.1", "libXrandr.so.2", "libXext.so.6", "libXfixes.so.3", "libXcursor.so.1", + "libXrender.so.1", "libXft.so.2", "libXi.so.6", "libXss.so.1", "libXpm.so.4", "libXau.so.6", "libXdmcp.so.6", + "libX11-xcb.so.1", "libxcb.so.1", "libxcb-xfixes.so.0", "libxcb-shape.so.0", "libxcb-shm.so.0", "libxcb-randr.so.0", + "libxcb-image.so.0", "libxcb-keysyms.so.1", "libxcb-xtest.so.0", "libxcb-glx.so.0", "libxcb-dri2.so.0", "libxcb-dri3.so.0", + "libXtst.so.6", "libXt.so.6", "libXcomposite.so.1", "libXdamage.so.1", "libXmu.so.6", "libxkbcommon.so.0", + "libxkbcommon-x11.so.0", "libpulse-simple.so.0", "libpulse.so.0", "libvulkan.so.1", "libvulkan.so", + "ld-linux-x86-64.so.2", "crashhandler.so", "libtcmalloc_minimal.so.0", "libtcmalloc_minimal.so.4" +}; +static int isEssentialLib(const char* name) { + for (int i=0; i<sizeof(essential_libs)/sizeof(essential_libs[0]); ++i) + if(!strcmp(name, essential_libs[i])) + return 1; + return 0; +} + extern char* libGL; library_t *NewLibrary(const char* path, box64context_t* context) { @@ -341,7 +359,10 @@ library_t *NewLibrary(const char* path, box64context_t* context) } } int notwrapped = FindInCollection(lib->name, &context->box64_emulated_libs); - int precise = (path && path[0]=='/')?1:0; + int essential = isEssentialLib(lib->name); + if(!notwrapped && box64_prefer_emulated && !essential) + notwrapped = 1; + int precise = (!box64_prefer_wrapped && !essential && path && path[0]=='/')?1:0; if(!notwrapped && precise && strstr(path, "libtcmalloc_minimal.so")) precise = 0; // allow native version for tcmalloc_minimum // check if name is libSDL_sound-1.0.so.1 but with SDL2 loaded, then try emulated first... diff --git a/src/library_list.h b/src/library_list.h index 04520348..03f3385f 100755 --- a/src/library_list.h +++ b/src/library_list.h @@ -154,6 +154,7 @@ GO("libcups.so.2", libcups) GO("libvulkan.so.1", vulkan) GO("libvulkan.so", vulkan) //GO("libwayland-client.so.0", waylandclient) +GO("libgbm.so.1", gbm) GO("libxml2.so.2", xml2) GO("libxslt.so.1", xslt) GO("libldap_r-2.4.so.2", ldapr) diff --git a/src/main.c b/src/main.c index ae2c21b9..208c251d 100755 --- a/src/main.c +++ b/src/main.c @@ -72,6 +72,7 @@ int box64_dynarec_trace = 0; int x11threads = 0; int x11glx = 1; int allow_missing_libs = 0; +int box64_prefer_emulated = 0; int box64_prefer_wrapped = 0; int fix_64bit_inodes = 0; int box64_mapclean = 0; @@ -659,7 +660,6 @@ void PrintHelp() { printf("You can also set some environment variables:\n"); printf(" BOX64_PATH is the box64 version of PATH (default is '.:bin')\n"); printf(" BOX64_LD_LIBRARY_PATH is the box64 version LD_LIBRARY_PATH (default is '.:lib:lib64')\n"); - printf(" BOX64_PREFER_WRAPPED if box64 will use wrapped libs even if the lib is specified with absolute path\n"); printf(" BOX64_LOG with 0/1/2/3 or NONE/INFO/DEBUG/DUMP to set the printed debug info (level 3 is level 2 + BOX64_DUMP)\n"); printf(" BOX64_DUMP with 0/1 to dump elf infos\n"); printf(" BOX64_NOBANNER with 0/1 to enable/disable the printing of box64 version and build at start\n"); @@ -691,6 +691,8 @@ void PrintHelp() { printf(" BOX64_LIBGL=libXXXX set the name (and optionnaly full path) for libGL.so.1\n"); printf(" BOX64_LD_PRELOAD=XXXX[:YYYYY] force loading XXXX (and YYYY...) libraries with the binary\n"); printf(" BOX64_ALLOWMISSINGLIBS with 1 to allow to continue even if a lib is missing (unadvised, will probably crash later)\n"); + printf(" BOX64_PREFER_EMULATED=1 to prefer emulated libs first (execpt for glibc, alsa, pulse, GL, vulkan and X11\n"); + printf(" BOX64_PREFER_WRAPPED if box64 will use wrapped libs even if the lib is specified with absolute path\n"); printf(" BOX64_NOPULSE=1 to disable the loading of pulseaudio libs\n"); printf(" BOX64_NOGTK=1 to disable the loading of wrapped gtk libs\n"); printf(" BOX64_NOVULKAN=1 to disable the loading of wrapped vulkan libs\n"); @@ -718,12 +720,24 @@ void LoadEnvVars(box64context_t *context) printf_log(LOG_INFO, "\n"); } } + // add libssl and libcrypto, prefer emulated version because of multiple version exist + AddPath("libssl.so.1", &context->box64_emulated_libs, 0); + AddPath("libssl.so.1.0.0", &context->box64_emulated_libs, 0); + AddPath("libcrypto.so.1", &context->box64_emulated_libs, 0); + AddPath("libcrypto.so.1.0.0", &context->box64_emulated_libs, 0); + if(getenv("BOX64_PREFER_WRAPPED")) { if (strcmp(getenv("BOX64_PREFER_WRAPPED"), "1")==0) { box64_prefer_wrapped = 1; printf_log(LOG_INFO, "BOX64: Prefer Wrapped libs\n"); } } + if(getenv("BOX64_PREFER_EMULATED")) { + if (strcmp(getenv("BOX64_PREFER_EMULATED"), "1")==0) { + box64_prefer_emulated = 1; + printf_log(LOG_INFO, "BOX64: Prefer Emulated libs\n"); + } + } if(getenv("BOX64_NOSIGSEGV")) { if (strcmp(getenv("BOX64_NOSIGSEGV"), "1")==0) { diff --git a/src/steam.c b/src/steam.c index ddbb7c6a..e944c452 100644 --- a/src/steam.c +++ b/src/steam.c @@ -22,7 +22,7 @@ void pressure_vessel(int argc, const char** argv, int nextarg) char *p = strchr(tmp, '='); *p ='\0'; ++p; setenv(tmp, p, 1); - printf_log(/*LOG_DEBUG*/LOG_INFO, "setenv(%s, %s, 1)\n", tmp, p); + printf_log(LOG_DEBUG, "setenv(%s, %s, 1)\n", tmp, p); } else if(strstr(argv[nextarg], "--env-if-host=STEAM_RUNTIME_LIBRARY_PATH=")==argv[nextarg]) { // transform RESSURE_VESSEL_APP_LD_LIBRARY_PATH to BOX86_ / BOX64_ LD_LIBRARY_PATH char tmp[strlen(argv[nextarg])]; @@ -31,19 +31,19 @@ void pressure_vessel(int argc, const char** argv, int nextarg) char *p = strchr(tmp, '='); *p ='\0'; ++p; setenv(tmp, p, 1); - printf_log(/*LOG_DEBUG*/LOG_INFO, "setenv(%s, %s, 1)\n", tmp, p); + printf_log(LOG_DEBUG, "setenv(%s, %s, 1)\n", tmp, p); tmp[3] = '6'; tmp[4] = '4'; setenv(tmp, p, 1); - printf_log(/*LOG_DEBUG*/LOG_INFO, "setenv(%s, %s, 1)\n", tmp, p); + printf_log(LOG_DEBUG, "setenv(%s, %s, 1)\n", tmp, p); } else if(!strcmp(argv[nextarg], "--")) { - printf_log(/*LOG_DEBUG*/LOG_INFO, "End of pressure-vessel-wrap parameters\n"); + printf_log(LOG_DEBUG, "End of pressure-vessel-wrap parameters\n"); }else { - printf_log(/*LOG_DEBUG*/LOG_INFO, "Ignored parameter: \"%s\"\n", argv[nextarg]); + printf_log(LOG_DEBUG, "Ignored parameter: \"%s\"\n", argv[nextarg]); } ++nextarg; } - printf_log(/*LOG_DEBUG*/LOG_INFO, "Ready to launch \"%s\", nextarg=%d, argc=%d\n", argv[nextarg], nextarg, argc); + printf_log(LOG_DEBUG, "Ready to launch \"%s\", nextarg=%d, argc=%d\n", argv[nextarg], nextarg, argc); const char* prog = argv[nextarg]; my_context = NewBox64Context(argc - nextarg); int x86 = my_context->box86path?FileIsX86ELF(argv[nextarg]):0; @@ -52,17 +52,19 @@ void pressure_vessel(int argc, const char** argv, int nextarg) const char** newargv = (const char**)calloc((argc-nextarg)+1+((x86 || x64)?1:0), sizeof(char*)); if(x86 || x64) { newargv[0] = x64?my_context->box64path:my_context->box86path; - printf_log(/*LOG_DEBUG*/LOG_INFO, "argv[%d]=\"%s\"\n", 0, newargv[0]); + printf_log(LOG_DEBUG, "argv[%d]=\"%s\"\n", 0, newargv[0]); for(int i=nextarg; i<argc; ++i) { - printf_log(/*LOG_DEBUG*/LOG_INFO, "argv[%d]=\"%s\"\n", 1+i-nextarg, argv[i]); + printf_log(LOG_DEBUG, "argv[%d]=\"%s\"\n", 1+i-nextarg, argv[i]); newargv[1+i-nextarg] = argv[i]; } } else { for(int i=nextarg; i<argc; ++i) { - printf_log(/*LOG_DEBUG*/LOG_INFO, "argv[%d]=\"%s\"\n", i-nextarg, argv[i]); + printf_log(LOG_DEBUG, "argv[%d]=\"%s\"\n", i-nextarg, argv[i]); newargv[i-nextarg] = argv[i]; } } + setenv("BOX64_PREFER_EMULATED", "1", 1); + setenv("BOX86_PREFER_EMULATED", "1", 1); //setenv("BOX64_TRACE_FILE", "/home/seb/trace64-%pid.txt", 1); //setenv("BOX86_TRACE_FILE", "/home/seb/trace86-%pid.txt", 1); @@ -71,7 +73,7 @@ void pressure_vessel(int argc, const char** argv, int nextarg) //setenv("BOX86_SHOWSEGV", "1", 1); //setenv("BOX64_SHOWSEGV", "1", 1); - printf_log(/*LOG_DEBUG*/LOG_INFO, "Run %s %s and wait\n", x86?"i386":(x64?"x86_64":""), argv[nextarg]); + printf_log(LOG_DEBUG, "Run %s %s and wait\n", x86?"i386":(x64?"x86_64":""), argv[nextarg]); pid_t v = vfork(); if(v==-1) { printf_log(LOG_NONE, "vfork failed!\n"); @@ -81,7 +83,7 @@ void pressure_vessel(int argc, const char** argv, int nextarg) if(!v) { // child process, exec the program... int ret = execvp(newargv[0], (char * const*)newargv); - printf_log(/*LOG_DEBUG*/LOG_INFO, "Error launching program: %d (%s)\n", ret, strerror(errno)); + printf_log(LOG_DEBUG, "Error launching program: %d (%s)\n", ret, strerror(errno)); exit(0); } else { // parent process, wait the end of child |