about summary refs log tree commit diff stats
path: root/src/main.c
diff options
context:
space:
mode:
authorptitSeb <sebastien.chev@gmail.com>2022-07-09 11:58:35 +0200
committerptitSeb <sebastien.chev@gmail.com>2022-07-09 11:58:35 +0200
commitec3786f86295b0fb769970bcb3c77b4ffffd7d48 (patch)
treeeeda9ecd7394e93eac2f759786ac3f7c19a1334b /src/main.c
parent0e761801deb4aa045e6052dee454973587e8dd4b (diff)
downloadbox64-ec3786f86295b0fb769970bcb3c77b4ffffd7d48.tar.gz
box64-ec3786f86295b0fb769970bcb3c77b4ffffd7d48.zip
Various improvement and some workaround to support musl binary (for #324)
Diffstat (limited to 'src/main.c')
-rwxr-xr-xsrc/main.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c
index 9cc99ddd..40b58412 100755
--- a/src/main.c
+++ b/src/main.c
@@ -83,6 +83,7 @@ int box64_mapclean = 0;
 int box64_zoom = 0;
 int box64_steam = 0;
 int box64_wine = 0;
+int box64_musl = 0;
 int box64_nopulse = 0;
 int box64_nogtk = 0;
 int box64_novulkan = 0;
@@ -1025,6 +1026,7 @@ int main(int argc, const char **argv, char **env) {
         pressure_vessel(argc, argv, nextarg+1);
     }
     #endif
+    int ld_libs_args = -1;
     // check if this is wine
     if(!strcmp(prog, "wine64")
      || !strcmp(prog, "wine64-development") 
@@ -1041,6 +1043,22 @@ int main(int argc, const char **argv, char **env) {
             exit(0);    // exiting, it doesn't work anyway
         }
         box64_wine = 1;
+    } else 
+    // check if ld-musl-x86_64.so.1 is used
+    if(strstr(prog, "ld-musl-x86_64.so.1")) {
+        printf_log(LOG_INFO, "BOX64: ld-musl detected, trying to workaround and use system ld-linux\n");
+        box64_musl = 1;
+        // skip ld-musl and go through args unti "--" is found, handling "--library-path" to add some libs to BOX64_LD_LIBRARY
+        ++nextarg;
+        while(strcmp(argv[nextarg], "--")) {
+            if(!strcmp(argv[nextarg], "--library-path")) {
+                ++nextarg;
+                ld_libs_args = nextarg;
+            }
+            ++nextarg;
+        }
+        ++nextarg;
+        prog = argv[nextarg];
     }
     // check if this is wineserver
     if(!strcmp(prog, "wineserver") || !strcmp(prog, "wineserver64") || (strlen(prog)>9 && !strcmp(prog+strlen(prog)-strlen("/wineserver"), "/wineserver"))) {
@@ -1055,6 +1073,9 @@ int main(int argc, const char **argv, char **env) {
 
     // check BOX64_LD_LIBRARY_PATH and load it
     LoadEnvVars(my_context);
+    // Append ld_list if it exist
+    if(ld_libs_args!=-1)
+        AppendList(&my_context->box64_ld_lib, argv[ld_libs_args], 1);
 
     my_context->box64path = ResolveFile(argv[0], &my_context->box64_path);
     // prepare all other env. var