]> git.proxmox.com Git - wasi-libc.git/commitdiff
Remove support for `__original_main`. (#295)
authorDan Gohman <dev@sunfishcode.online>
Wed, 1 Jun 2022 15:51:20 +0000 (08:51 -0700)
committerGitHub <noreply@github.com>
Wed, 1 Jun 2022 15:51:20 +0000 (08:51 -0700)
* Remove support for `__original_main`.

This was used in old LLVM versions. Recent LLVM versions all emit either
`__main_void` or `__main_argv_argc`, so we can use those directly.

* Update the CI to use LLVM 14.0.0.

.github/workflows/main.yml
expected/wasm32-wasi/defined-symbols.txt
expected/wasm32-wasi/undefined-symbols.txt
libc-bottom-half/crt/crt1-command.c
libc-bottom-half/crt/crt1.c
libc-bottom-half/sources/__main_argc_argv.c [deleted file]
libc-bottom-half/sources/__original_main.c [deleted file]

index 2fdc5d5912f6301a4dc8acdf32637f64b3941667..83d3aa5d738a054595fc854ff62fc21bd71bb3ed 100644 (file)
@@ -16,8 +16,8 @@ jobs:
     - name: Install LLVM tools (Windows)
       shell: bash
       run: |
-        curl -fsSLO https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/LLVM-10.0.0-win64.exe
-        7z x LLVM-10.0.0-win64.exe -y -o"llvm"
+        curl -fsSLO https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/LLVM-14.0.0-win64.exe
+        7z x LLVM-14.0.0-win64.exe -y -o"llvm"
         echo "$(pwd)/llvm/bin" >> $GITHUB_PATH
         echo "CC=$(pwd)/llvm/bin/clang.exe" >> $GITHUB_ENV
         echo "AR=$(pwd)/llvm/bin/llvm-ar.exe" >> $GITHUB_ENV
@@ -35,8 +35,8 @@ jobs:
     - name: Install LLVM tools (MacOS)
       shell: bash
       run: |
-        curl -sSfL https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-apple-darwin.tar.xz | tar xJf -
-        export CLANG_DIR=`pwd`/clang+llvm-10.0.0-x86_64-apple-darwin/bin
+        curl -sSfL https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-apple-darwin.tar.xz | tar xJf -
+        export CLANG_DIR=`pwd`/clang+llvm-14.0.0-x86_64-apple-darwin/bin
         echo "$CLANG_DIR" >> $GITHUB_PATH
         echo "CC=$CLANG_DIR/clang" >> $GITHUB_ENV
         echo "AR=$CLANG_DIR/llvm-ar" >> $GITHUB_ENV
@@ -46,8 +46,8 @@ jobs:
     - name: Install LLVM tools (Linux)
       shell: bash
       run: |
-        curl -sSfL https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.0/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz | tar xJf -
-        export CLANG_DIR=`pwd`/clang+llvm-10.0.0-x86_64-linux-gnu-ubuntu-18.04/bin
+        curl -sSfL https://github.com/llvm/llvm-project/releases/download/llvmorg-14.0.0/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04.tar.xz | tar xJf -
+        export CLANG_DIR=`pwd`/clang+llvm-14.0.0-x86_64-linux-gnu-ubuntu-18.04/bin
         echo "$CLANG_DIR" >> $GITHUB_PATH
         echo "CC=$CLANG_DIR/clang" >> $GITHUB_ENV
         echo "AR=$CLANG_DIR/llvm-ar" >> $GITHUB_ENV
index ba995bae282dd189e45557dbc6b0a41bfb900054..69242c75dd5b36fd43bcecef0822b19bc72fa6fe 100644 (file)
@@ -146,7 +146,6 @@ __log2f_data
 __log_data
 __logf_data
 __lseek
-__main_argc_argv
 __main_void
 __math_divzero
 __math_divzerof
@@ -170,7 +169,6 @@ __ofl_lock
 __ofl_unlock
 __optpos
 __optreset
-__original_main
 __overflow
 __p1evll
 __pio2_hi
index 7a659e776bbf7ca8dbd1c7ff2534e5e11eceb2ed..b9cdb34322474aedd4f98dc730dc27b1848377d8 100644 (file)
@@ -58,6 +58,7 @@ __imported_wasi_snapshot_preview1_sock_send
 __imported_wasi_snapshot_preview1_sock_shutdown
 __letf2
 __lttf2
+__main_argc_argv
 __netf2
 __stack_pointer
 __subtf3
@@ -65,4 +66,3 @@ __trunctfdf2
 __trunctfsf2
 __unordtf2
 __wasm_call_ctors
-main
index 93279fbed3dbd22a29810ecd0bf717fc8976f7a6..706ab97e69b0272aa7bd9a57ce095051944f09c9 100644 (file)
@@ -1,15 +1,15 @@
 #include <wasi/api.h>
 #include <stdlib.h>
 extern void __wasm_call_ctors(void);
-extern int __original_main(void);
+extern int __main_void(void);
 extern void __wasm_call_dtors(void);
 
 __attribute__((export_name("_start")))
 void _start(void) {
-    // Call `__original_main` which will either be the application's zero-argument
-    // `__original_main` function or a libc routine which calls `__main_void`.
-    // TODO: Call `main` directly once we no longer have to support old compilers.
-    int r = __original_main();
+    // Call `__main_void` which will either be the application's zero-argument
+    // `__main_void` function or a libc routine which obtains the command-line
+    // arguments and calls `__main_argv_argc`.
+    int r = __main_void();
 
     // If main exited successfully, just return, otherwise call `exit`.
     if (r != 0) {
index 5e164dddba3d3e27cae3513f739e1e9cfec56eec..b3906dc5f36ced774262b3952ab75d2ab9a0cb9f 100644 (file)
@@ -1,6 +1,6 @@
 #include <wasi/api.h>
 extern void __wasm_call_ctors(void);
-extern int __original_main(void);
+extern int __main_void(void);
 extern void __wasm_call_dtors(void);
 
 __attribute__((export_name("_start")))
@@ -8,10 +8,10 @@ void _start(void) {
     // The linker synthesizes this to call constructors.
     __wasm_call_ctors();
 
-    // Call `__original_main` which will either be the application's zero-argument
-    // `__original_main` function or a libc routine which calls `__main_void`.
-    // TODO: Call `main` directly once we no longer have to support old compilers.
-    int r = __original_main();
+    // Call `__main_void` which will either be the application's zero-argument
+    // `__main_void` function or a libc routine which obtains the command-line
+    // arguments and calls `__main_argv_argc`.
+    int r = __main_void();
 
     // Call atexit functions, destructors, stdio cleanup, etc.
     __wasm_call_dtors();
diff --git a/libc-bottom-half/sources/__main_argc_argv.c b/libc-bottom-half/sources/__main_argc_argv.c
deleted file mode 100644 (file)
index decaa2d..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// New compilers define `__main_argc_argv`. If that doesn't exist, we
-// may get called here. Old compilers define `main` expecting an
-// argv/argc, so call that.
-// TODO: Remove this layer when we no longer have to support old compilers.
-int __wasilibc_main(int argc, char *argv[]) asm("main");
-
-__attribute__((weak, nodebug))
-int __main_argc_argv(int argc, char *argv[]) {
-    return __wasilibc_main(argc, argv);
-}
diff --git a/libc-bottom-half/sources/__original_main.c b/libc-bottom-half/sources/__original_main.c
deleted file mode 100644 (file)
index 73564d4..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-// Old compilers define `__original_main`. If that doesn't exist, we
-// get called here. New compilers define `__main_void`. If that doesn't
-// exist, we'll try something else.
-// TODO: Remove this layer when we no longer have to support old compilers.
-int __main_void(void);
-
-__attribute__((weak))
-int __original_main(void) {
-    return __main_void();
-}