From 49bbe94381abaeea02e26e694de0677fbc53f7c8 Mon Sep 17 00:00:00 2001 From: Samuel Gomes Date: Thu, 7 Mar 2024 20:18:20 +0530 Subject: [PATCH 1/4] Remove objcopy dependency for DATA --- Makefile | 8 ------- docs/build-system.md | 1 - source/qb64pe.bas | 53 +++++++++++--------------------------------- 3 files changed, 13 insertions(+), 49 deletions(-) diff --git a/Makefile b/Makefile index eff339d19..9c13848a3 100644 --- a/Makefile +++ b/Makefile @@ -373,15 +373,10 @@ ifeq ($(OS),win) endif endif -ifneq ($(filter y,$(DEP_DATA)),) - EXE_OBJS += $(PATH_INTERNAL_TEMP)/data.o -endif - ifneq ($(filter y,$(DEP_EMBED)),) EXE_OBJS += $(PATH_INTERNAL_TEMP)/embedded.o endif - QBLIB := $(PATH_INTERNAL_C)/$(QBLIB_NAME).o $(QBLIB): $(PATH_INTERNAL_C)/libqb.cpp @@ -408,9 +403,6 @@ ifeq ($(OS),osx) $(CXX) $(CXXFLAGS) $< -c -o $@ endif -$(PATH_INTERNAL_TEMP)/data.o: $(PATH_INTERNAL_TEMP)/data.bin - $(OBJCOPY) -Ibinary $(OBJCOPY_FLAGS) $< $@ - $(PATH_INTERNAL_TEMP)/embedded.o: $(PATH_INTERNAL_TEMP)/embedded.cpp $(CXX) $(CXXFLAGS) $< -c -o $@ diff --git a/docs/build-system.md b/docs/build-system.md index 7894112a8..e2dea76c4 100644 --- a/docs/build-system.md +++ b/docs/build-system.md @@ -128,7 +128,6 @@ These flags controls whether certain dependencies are compiled in or not. All of | `DEP_FONT` | Enables various `_FONT` related support. | | `DEP_DEVICEINPUT` | Enables game controller input support. | | `DEP_ZLIB` | Adds `_DEFLATE` and `_INFLATE` support. | -| `DEP_DATA` | Compiles in data produced via `DATA` statements. | | `DEP_EMBED` | Compiles in data embedded via `$EMBED` statements. | | `DEP_CONSOLE` | On Windows, this gives the program console support (graphical support is still allowed) | | `DEP_CONSOLE_ONLY` | Same as `DEP_CONSOLE`, but also removes GLUT and graphics support. | diff --git a/source/qb64pe.bas b/source/qb64pe.bas index b5d2e536f..77e7af112 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -221,8 +221,6 @@ IF INSTR(_OS$, "[LINUX]") THEN os$ = "LNX" DIM SHARED MacOSX AS LONG IF INSTR(_OS$, "[MACOSX]") THEN MacOSX = 1 -DIM SHARED inline_DATA -IF MacOSX OR INSTR(_OS$, "[ARM]") THEN inline_DATA = 1 DIM SHARED BATCHFILE_EXTENSION AS STRING BATCHFILE_EXTENSION = ".bat" @@ -440,7 +438,7 @@ END IF '255 A qb error happened in the IDE (compiler->ide) ' note: detected by the fact that ideerror was not set to 0 ' [255] -'$include:'./utilities/hash.bi' +'$INCLUDE:'./utilities/hash.bi' TYPE Label_Type State AS _UNSIGNED _BYTE '0=label referenced, 1=label created @@ -11961,42 +11959,18 @@ IF DataOffset = 0 THEN ELSE - IF inline_DATA = 0 THEN - IF os$ = "WIN" THEN - IF OS_BITS = 32 THEN - x$ = CHR$(0): WriteBufRawData DataBinBuf, x$ - WriteBufLine GlobTxtBuf, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - WriteBufLine GlobTxtBuf, "extern char *binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - WriteBufLine GlobTxtBuf, "}" - WriteBufLine GlobTxtBuf, "uint8 *data=(uint8*)&binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - ELSE - x$ = CHR$(0): WriteBufRawData DataBinBuf, x$ - WriteBufLine GlobTxtBuf, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - WriteBufLine GlobTxtBuf, "extern char *_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - WriteBufLine GlobTxtBuf, "}" - WriteBufLine GlobTxtBuf, "uint8 *data=(uint8*)&_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - END IF - END IF - IF os$ = "LNX" THEN - x$ = CHR$(0): WriteBufRawData DataBinBuf, x$ - WriteBufLine GlobTxtBuf, "extern " + CHR$(34) + "C" + CHR$(34) + "{" - WriteBufLine GlobTxtBuf, "extern char *_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - WriteBufLine GlobTxtBuf, "}" - WriteBufLine GlobTxtBuf, "uint8 *data=(uint8*)&_binary_internal_temp" + tempfolderindexstr2$ + "_data_bin_start;" - END IF - ELSE - 'inline data - ff = OpenBuffer%("B", tmpdir$ + "data.bin") - x$ = ReadBufRawData$(ff, GetBufLen&(ff)) - x2$ = "uint8 inline_data[]={" - FOR i = 1 TO LEN(x$) - x2$ = x2$ + inlinedatastr$(ASC(x$, i)) - NEXT - x2$ = x2$ + "0};" - WriteBufLine GlobTxtBuf, x2$ - WriteBufLine GlobTxtBuf, "uint8 *data=&inline_data[0];" - x$ = "": x2$ = "" - END IF + 'inline data + ff = OpenBuffer%("B", tmpdir$ + "data.bin") + x$ = ReadBufRawData$(ff, GetBufLen&(ff)) + x2$ = "uint8 inline_data[]={" + FOR i = 1 TO LEN(x$) + x2$ = x2$ + inlinedatastr$(ASC(x$, i)) + NEXT + x2$ = x2$ + "0};" + WriteBufLine GlobTxtBuf, x2$ + WriteBufLine GlobTxtBuf, "uint8 *data=&inline_data[0];" + x$ = "": x2$ = "" + END IF IF Debug THEN PRINT #9, "Beginning generation of code for saving/sharing common array data..." @@ -12600,7 +12574,6 @@ IF DEPENDENCY(DEPENDENCY_SCREENIMAGE) THEN makedeps$ = makedeps$ + " DEP_SCREENI IF DEPENDENCY(DEPENDENCY_LOADFONT) THEN makedeps$ = makedeps$ + " DEP_FONT=y" IF DEPENDENCY(DEPENDENCY_DEVICEINPUT) THEN makedeps$ = makedeps$ + " DEP_DEVICEINPUT=y" IF DEPENDENCY(DEPENDENCY_ZLIB) THEN makedeps$ = makedeps$ + " DEP_ZLIB=y" -IF inline_DATA = 0 AND DataOffset THEN makedeps$ = makedeps$ + " DEP_DATA=y" IF DEPENDENCY(DEPENDENCY_EMBED) THEN makedeps$ = makedeps$ + " DEP_EMBED=y" IF ConsoleOn THEN makedeps$ = makedeps$ + " DEP_CONSOLE=y" IF ExeIconSet OR VersionInfoSet THEN makedeps$ = makedeps$ + " DEP_ICON_RC=y" From c8e4098fb233fe677f0eb59b714e15f9470af9d7 Mon Sep 17 00:00:00 2001 From: Samuel Gomes <47574584+a740g@users.noreply.github.com> Date: Sun, 10 Mar 2024 18:56:08 +0530 Subject: [PATCH 2/4] Optimize inline-data generation logic --- setup_mingw.cmd | 8 ++++---- source/qb64pe.bas | 22 ++++++++++++++++------ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/setup_mingw.cmd b/setup_mingw.cmd index 5250603a5..c255515ad 100644 --- a/setup_mingw.cmd +++ b/setup_mingw.cmd @@ -68,11 +68,11 @@ rem MINGW_DIR is actually the internal directory name inside the zip / 7z file rem It needs to be updated whenever the toolchains are updated if "%ARCH%" == "ARM" ( if %BITS% == 64 ( - set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-aarch64.zip" - set MINGW_DIR=llvm-mingw-20231128-ucrt-aarch64 + set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240308/llvm-mingw-20240308-ucrt-aarch64.zip" + set MINGW_DIR=llvm-mingw-20240308-ucrt-aarch64 ) else ( - set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20231128/llvm-mingw-20231128-ucrt-armv7.zip" - set MINGW_DIR=llvm-mingw-20231128-ucrt-armv7 + set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240308/llvm-mingw-20240308-ucrt-armv7.zip" + set MINGW_DIR=llvm-mingw-20240308-ucrt-armv7 ) set MINGW_TEMP_FILE=temp.zip ) else ( diff --git a/source/qb64pe.bas b/source/qb64pe.bas index 77e7af112..64f0b4d6a 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -228,9 +228,9 @@ IF os$ = "LNX" THEN BATCHFILE_EXTENSION = ".sh" IF MacOSX THEN BATCHFILE_EXTENSION = ".command" -DIM inlinedatastr(255) AS STRING +DIM inlinedatastr(0 TO 255) AS STRING FOR i = 0 TO 255 - inlinedatastr(i) = str2$(i) + "," + inlinedatastr(i) = "0x" + RIGHT$("0" + HEX$(i), 2) + "," NEXT @@ -11962,13 +11962,23 @@ ELSE 'inline data ff = OpenBuffer%("B", tmpdir$ + "data.bin") x$ = ReadBufRawData$(ff, GetBufLen&(ff)) - x2$ = "uint8 inline_data[]={" - FOR i = 1 TO LEN(x$) - x2$ = x2$ + inlinedatastr$(ASC(x$, i)) + + idsL = LEN(inlinedatastr(255)) + xL = LEN(x$) + + x2$ = SPACE$(xL * idsL) ' pre-allocate buffer + + x2Ofs = 1 + FOR i = 1 TO xL + MID$(x2$, x2Ofs, idsL) = inlinedatastr(ASC(x$, i)) + x2Ofs = x2Ofs + idsL NEXT - x2$ = x2$ + "0};" + + WriteBufLine GlobTxtBuf, "uint8 inline_data[]={" WriteBufLine GlobTxtBuf, x2$ + WriteBufLine GlobTxtBuf, "0};" WriteBufLine GlobTxtBuf, "uint8 *data=&inline_data[0];" + x$ = "": x2$ = "" END IF From ab56aeff93a698e27e0df06c924143117088968d Mon Sep 17 00:00:00 2001 From: Samuel Gomes <47574584+a740g@users.noreply.github.com> Date: Mon, 11 Mar 2024 08:35:17 +0530 Subject: [PATCH 3/4] Reduce memory usage --- source/qb64pe.bas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/qb64pe.bas b/source/qb64pe.bas index 64f0b4d6a..22259c7cc 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -230,7 +230,7 @@ IF MacOSX THEN BATCHFILE_EXTENSION = ".command" DIM inlinedatastr(0 TO 255) AS STRING FOR i = 0 TO 255 - inlinedatastr(i) = "0x" + RIGHT$("0" + HEX$(i), 2) + "," + inlinedatastr(i) = str2(i) + "," NEXT From 4d771e3a9ac61bf332732bc3648f306cd57e32dc Mon Sep 17 00:00:00 2001 From: Samuel Gomes <47574584+a740g@users.noreply.github.com> Date: Sun, 24 Mar 2024 23:42:50 +0530 Subject: [PATCH 4/4] Update to llvm-mingw 20240320 for WoA targets --- setup_mingw.cmd | 8 ++++---- source/qb64pe.bas | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/setup_mingw.cmd b/setup_mingw.cmd index c255515ad..843e5695e 100644 --- a/setup_mingw.cmd +++ b/setup_mingw.cmd @@ -68,11 +68,11 @@ rem MINGW_DIR is actually the internal directory name inside the zip / 7z file rem It needs to be updated whenever the toolchains are updated if "%ARCH%" == "ARM" ( if %BITS% == 64 ( - set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240308/llvm-mingw-20240308-ucrt-aarch64.zip" - set MINGW_DIR=llvm-mingw-20240308-ucrt-aarch64 + set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240320/llvm-mingw-20240320-ucrt-aarch64.zip" + set MINGW_DIR=llvm-mingw-20240320-ucrt-aarch64 ) else ( - set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240308/llvm-mingw-20240308-ucrt-armv7.zip" - set MINGW_DIR=llvm-mingw-20240308-ucrt-armv7 + set URL="https://github.com/mstorsjo/llvm-mingw/releases/download/20240320/llvm-mingw-20240320-ucrt-armv7.zip" + set MINGW_DIR=llvm-mingw-20240320-ucrt-armv7 ) set MINGW_TEMP_FILE=temp.zip ) else ( diff --git a/source/qb64pe.bas b/source/qb64pe.bas index 22259c7cc..28c0f3a4e 100644 --- a/source/qb64pe.bas +++ b/source/qb64pe.bas @@ -230,7 +230,7 @@ IF MacOSX THEN BATCHFILE_EXTENSION = ".command" DIM inlinedatastr(0 TO 255) AS STRING FOR i = 0 TO 255 - inlinedatastr(i) = str2(i) + "," + inlinedatastr(i) = str2$(i) + "," NEXT