From b0e659cb138886461717d358b3a1a9c99db7efc0 Mon Sep 17 00:00:00 2001 From: Tao Yu Date: Wed, 3 May 2023 00:12:30 +0800 Subject: [PATCH] fix windows 64-bit cgo interface --- core/plugin/LogtailPlugin.h | 4 ++-- docs/cn/installation/release-notes.md | 4 ++-- scripts/windows32_build.bat | 25 ++++++++++++++----------- scripts/windows64_build.bat | 25 ++++++++++++++----------- 4 files changed, 32 insertions(+), 26 deletions(-) diff --git a/core/plugin/LogtailPlugin.h b/core/plugin/LogtailPlugin.h index 1d6ded670f..e44c46c65f 100644 --- a/core/plugin/LogtailPlugin.h +++ b/core/plugin/LogtailPlugin.h @@ -28,7 +28,7 @@ extern "C" { // The definition of Golang type is copied from PluginAdaptor.h that // generated by `go build -buildmode=c-shared ...`. -#if defined(__linux__) || defined(__APPLE__) // *unix amd64 +#if defined(__linux__) || defined(__APPLE__) || defined(_WIN64) // 64-bit system typedef long long GoInt64; typedef GoInt64 GoInt; typedef struct { @@ -40,7 +40,7 @@ typedef struct { GoInt len; GoInt cap; } GoSlice; -#elif defined(_MSC_VER) // x86 Go + x86 MinGW + Win32 VS. +#elif defined(_WIN32) // x86 Go + x86 MinGW + Win32 VS. typedef long long GoInt64; typedef int GoInt32; typedef GoInt32 GoInt; diff --git a/docs/cn/installation/release-notes.md b/docs/cn/installation/release-notes.md index abb421824b..cc3e23107e 100644 --- a/docs/cn/installation/release-notes.md +++ b/docs/cn/installation/release-notes.md @@ -38,13 +38,13 @@ | -------------------------------------------------------------------------------------------------------------------------------------------- | ----- | ------ | ---------------------------------------------------------------- | | [ilogtail-1.5.0.linux-amd64.tar.gz](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.5.0/ilogtail-1.5.0.linux-amd64.tar.gz) | Linux | x86-64 | ccb7e637bc7edc4e9fe22ab3ac79cedee63d80678711e0efc77122387ec73882 | | [ilogtail-1.5.0.linux-arm64.tar.gz](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.5.0/ilogtail-1.5.0.linux-arm64.tar.gz) | Linux | arm64 | f1d7940e08ee51f2c66d963d91c16903658ab1e0fc856002351248c94d0e6b0a | -| [ilogtail-1.5.0.windows-amd64.zip](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.5.0/ilogtail-1.5.0.windows-amd64.zip) | Linux | x86-64 | f7ba5c913839f86d4b589b6573e4f87f13b36fa61db246abf652734500b76ec3 | +| [ilogtail-1.5.0.windows-amd64.zip](https://ilogtail-community-edition.oss-cn-shanghai.aliyuncs.com/1.5.0/ilogtail-1.5.0.windows-amd64.zip) | Windows | x86-64 | 7b3ccbfcca18e1ffeb2e5db06b32fbcac3e8b7ecf8113a7006891bbe3c1a5a84 | ### Docker 镜像 **Docker Pull 命令** -``` +``` bash docker pull sls-opensource-registry.cn-shanghai.cr.aliyuncs.com/ilogtail-community-edition/ilogtail:1.5.0 ``` diff --git a/scripts/windows32_build.bat b/scripts/windows32_build.bat index f720a13bcb..4a39802393 100644 --- a/scripts/windows32_build.bat +++ b/scripts/windows32_build.bat @@ -19,19 +19,22 @@ set P1Path=%P1Path%%content%\ goto begin :end -set ILOGTAIL_PLUGIN_SRC_PATH=%P1Path% +set ILOGTAIL_PLUGIN_SRC_PATH="%P1Path%" +set ILOGTAIL_PLUGIN_SRC_UNIX_PATH=%ILOGTAIL_PLUGIN_SRC_PATH:\=/% REM Change to where boost_1_68_0 locates set BOOST_ROOT=C:\workspace\boost_1_68_0 -REM Change to where ilogtail-deps.windows-386 locates, path seperator must be / -set ILOGTAIL_DEPS_PATH=C:/workspace/ilogtail-deps.windows-386 +REM Change to where ilogtail-deps.windows-386 locates +set ILOGTAIL_DEPS_PATH=C:\workspace\ilogtail-deps.windows-386 +set ILOGTAIL_DEPS_PATH=%ILOGTAIL_DEPS_PATH:\=/% REM Change to where cmake locates -set CMAKE_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake +set CMAKE_BIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake" REM Change to where devenv locates -set DEVENV_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com +set DEVENV_BIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com" REM Change to where mingw locates set MINGW_PATH=C:\workspace\mingw32\bin set OUTPUT_DIR=%ILOGTAIL_PLUGIN_SRC_PATH%\output +set OUTPUT_UNIX_DIR=%OUTPUT_DIR:\=/% set ILOGTAIL_CORE_BUILD_PATH=%ILOGTAIL_PLUGIN_SRC_PATH%\core\build go env -w GOPROXY="https://goproxy.cn,direct" @@ -45,18 +48,18 @@ REM Clean up IF exist %OUTPUT_DIR% ( rd /s /q %OUTPUT_DIR% ) mkdir %OUTPUT_DIR% -REM Build C++ core(ilogtail.exe、PluginAdapter.dll) +REM Build C++ core (ilogtail.exe, PluginAdapter.dll) echo begin to compile core cd %ILOGTAIL_PLUGIN_SRC_PATH%\core IF exist build ( rd /s /q build ) mkdir build cd build -"%CMAKE_BIN%" -DCMAKE_BUILD_TYPE=Release -DLOGTAIL_VERSION=%ILOGTAIL_VERSION% -DDEPS_ROOT=%ILOGTAIL_DEPS_PATH% .. +%CMAKE_BIN% -DCMAKE_BUILD_TYPE=Release -DLOGTAIL_VERSION=%ILOGTAIL_VERSION% -DDEPS_ROOT=%ILOGTAIL_DEPS_PATH% .. if not %ERRORLEVEL% == 0 ( echo Run cmake failed. goto quit ) -"%DEVENV_BIN%" logtail.sln /Build "Release|Win32" 1>build.stdout 2>build.stderr +%DEVENV_BIN% logtail.sln /Build "Release|Win32" 1>build.stdout 2>build.stderr if not %ERRORLEVEL% == 0 ( echo Build iLogtail source failed. goto quit @@ -70,16 +73,16 @@ del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all.go del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_debug.go del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_windows.go del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_linux.go -go run -mod=mod "%ILOGTAIL_PLUGIN_SRC_PATH%\tools\builder" -root-dir="%ILOGTAIL_PLUGIN_SRC_PATH%" -config="plugins.yml,external_plugins.yml" -modfile="go.mod" +go run -mod=mod %ILOGTAIL_PLUGIN_SRC_UNIX_PATH%/tools/builder -root-dir=%ILOGTAIL_PLUGIN_SRC_UNIX_PATH% -config="plugins.yml,external_plugins.yml" -modfile="go.mod" echo generating plugins finished successfully -REM Build plugins(PluginBase.dll、PluginBase.h) +REM Build plugins(PluginBase.dll, PluginBase.h) echo Begin to build plugins... IF exist %OUTPUT_DIR% ( rd /s /q %OUTPUT_DIR% ) mkdir %OUTPUT_DIR% xcopy /Y %ILOGTAIL_CORE_BUILD_PATH%\plugin\Release\PluginAdapter.dll %ILOGTAIL_PLUGIN_SRC_PATH%\pkg\logtail set LDFLAGS="-X "github.com/alibaba/ilogtail/pluginmanager.BaseVersion=%ILOGTAIL_VERSION%"" -go build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o output\PluginBase.dll %ILOGTAIL_PLUGIN_SRC_PATH%/plugin_main +go build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o %OUTPUT_UNIX_DIR%/PluginBase.dll %ILOGTAIL_PLUGIN_SRC_UNIX_PATH%/plugin_main if not %ERRORLEVEL% == 0 ( echo Build iLogtail plugin source failed. goto quit diff --git a/scripts/windows64_build.bat b/scripts/windows64_build.bat index e9fe49b297..cd757860f4 100644 --- a/scripts/windows64_build.bat +++ b/scripts/windows64_build.bat @@ -19,19 +19,22 @@ set P1Path=%P1Path%%content%\ goto begin :end -set ILOGTAIL_PLUGIN_SRC_PATH=%P1Path% +set ILOGTAIL_PLUGIN_SRC_PATH="%P1Path%" +set ILOGTAIL_PLUGIN_SRC_UNIX_PATH=%ILOGTAIL_PLUGIN_SRC_PATH:\=/% REM Change to where boost_1_68_0 locates set BOOST_ROOT=C:\workspace\boost_1_68_0 -REM Change to where ilogtail-deps.windows-x64 locates, path seperator must be / -set ILOGTAIL_DEPS_PATH=C:/workspace/ilogtail-deps.windows-x64 +REM Change to where ilogtail-deps.windows-x64 locates +set ILOGTAIL_DEPS_PATH=C:\workspace\ilogtail-deps.windows-x64 +set ILOGTAIL_DEPS_PATH=%ILOGTAIL_DEPS_PATH:\=/% REM Change to where cmake locates -set CMAKE_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake +set CMAKE_BIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\CMake\CMake\bin\cmake" REM Change to where devenv locates -set DEVENV_BIN=C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com +set DEVENV_BIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\devenv.com" REM Change to where mingw locates set MINGW_PATH=C:\workspace\mingw64\bin set OUTPUT_DIR=%ILOGTAIL_PLUGIN_SRC_PATH%\output +set OUTPUT_UNIX_DIR=%OUTPUT_DIR:\=/% set ILOGTAIL_CORE_BUILD_PATH=%ILOGTAIL_PLUGIN_SRC_PATH%\core\build go env -w GOPROXY="https://goproxy.cn,direct" @@ -45,18 +48,18 @@ REM Clean up IF exist %OUTPUT_DIR% ( rd /s /q %OUTPUT_DIR% ) mkdir %OUTPUT_DIR% -REM Build C++ core(ilogtail.exe、PluginAdapter.dll) +REM Build C++ core(ilogtail.exe, PluginAdapter.dll) echo begin to compile core cd %ILOGTAIL_PLUGIN_SRC_PATH%\core IF exist build ( rd /s /q build ) mkdir build cd build -"%CMAKE_BIN%" -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DLOGTAIL_VERSION=%ILOGTAIL_VERSION% -DDEPS_ROOT=%ILOGTAIL_DEPS_PATH% .. +%CMAKE_BIN% -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release -DLOGTAIL_VERSION=%ILOGTAIL_VERSION% -DDEPS_ROOT=%ILOGTAIL_DEPS_PATH% .. if not %ERRORLEVEL% == 0 ( echo Run cmake failed. goto quit ) -"%DEVENV_BIN%" logtail.sln /Build "Release|x64" 1>build.stdout 2>build.stderr +%DEVENV_BIN% logtail.sln /Build "Release|x64" 1>build.stdout 2>build.stderr if not %ERRORLEVEL% == 0 ( echo Build iLogtail source failed. goto quit @@ -70,16 +73,16 @@ del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all.go del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_debug.go del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_windows.go del /f/s/q %ILOGTAIL_PLUGIN_SRC_PATH%\plugins\all\all_linux.go -go run -mod=mod "%ILOGTAIL_PLUGIN_SRC_PATH%\tools\builder" -root-dir="%ILOGTAIL_PLUGIN_SRC_PATH%" -config="plugins.yml,external_plugins.yml" -modfile="go.mod" +go run -mod=mod %ILOGTAIL_PLUGIN_SRC_UNIX_PATH%/tools/builder -root-dir=%ILOGTAIL_PLUGIN_SRC_UNIX_PATH% -config="plugins.yml,external_plugins.yml" -modfile="go.mod" echo generating plugins finished successfully -REM Build plugins(PluginBase.dll、PluginBase.h) +REM Build plugins (PluginBase.dll, PluginBase.h) echo Begin to build plugins... IF exist %OUTPUT_DIR% ( rd /s /q %OUTPUT_DIR% ) mkdir %OUTPUT_DIR% xcopy /Y %ILOGTAIL_CORE_BUILD_PATH%\plugin\Release\PluginAdapter.dll %ILOGTAIL_PLUGIN_SRC_PATH%\pkg\logtail set LDFLAGS="-X "github.com/alibaba/ilogtail/pluginmanager.BaseVersion=%ILOGTAIL_VERSION%"" -go build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o output\PluginBase.dll %ILOGTAIL_PLUGIN_SRC_PATH%/plugin_main +go build -mod=mod -buildmode=c-shared -ldflags=%LDFLAGS% -o %OUTPUT_UNIX_DIR%/PluginBase.dll %ILOGTAIL_PLUGIN_SRC_UNIX_PATH%/plugin_main if not %ERRORLEVEL% == 0 ( echo Build iLogtail plugin source failed. goto quit