embeddedartistry / libmemory

Embedded systems memory management library. Implementations for malloc(), free(), and other useful memory management functions
https://embeddedartistry.com
MIT License
216 stars 44 forks source link

Error libmemory at compiling time #17

Closed BastienMac closed 5 years ago

BastienMac commented 6 years ago

file_updated.tar.gz

Issue Template

Context

Please provide any relevant information about your setup. This is important in case the issue is not reproducible except for under certain conditions.

By the way, I'm compiling usin the c99 flag

Expected Behavior

It should compile. I haven't tested the lib yet so I don't know if it works.

Current Behavior

I'm sorry, I'm not sure that it should be notified in an issue...

There were some errors at compiling time :

Premake did not work

I had to re-install it from https://premake.github.io/download.html to libmemory-master/build/bin/Linux

Erros themselfs

I put the updated file the tar.gz if you want to take a look, there are not a lo of things to update The errors details are in the part "Failure Logs"

Linking libmemory_freertos ==== Building libmemory_freelist_UnitTests (debug_x86_64) ====

In libmemory-master/test/src/aligned_malloc.c

==== Building libmemory_freelist_UnitTests (debug_x86_64) ====

In libmemory-master/test/src/malloc_freelist.c

==== Building libmemory_freelist_UnitTests (debug_x86_64) ====

In libmemory-master/test/support/memory.c corrected by :

At linking time

I had to re-install cmocka from this https://cmocka.org/files/1.1/ to libmemory-master/arch/x86_64/lib/cmocka

And even with this I got these warnings : Linking libmemory_freelist_UnitTests make[1] : on quitte le répertoire « /home/macerab/software/libmemory-master/build/gen » Warning: ignoring unsupported tag ALLOW_UNICODE_NAMES =' at line 79, file docs/Doxyfile Warning: ignoring unsupported tagTOC_INCLUDE_HEADINGS =' at line 313, file docs/Doxyfile Warning: ignoring unsupported tag GROUP_NESTED_COMPOUNDS =' at line 370, file docs/Doxyfile Warning: ignoring unsupported tagHIDE_COMPOUND_REFERENCE=' at line 541, file docs/Doxyfile Warning: ignoring unsupported tag SHOW_GROUPED_MEMB_INC =' at line 554, file docs/Doxyfile Warning: ignoring unsupported tagWARN_AS_ERROR =' at line 765, file docs/Doxyfile Warning: ignoring unsupported tag LATEX_EXTRA_STYLESHEET =' at line 1743, file docs/Doxyfile Warning: ignoring unsupported tagLATEX_TIMESTAMP =' at line 1810, file docs/Doxyfile Warning: ignoring unsupported tag RTF_SOURCE_CODE =' at line 1876, file docs/Doxyfile Warning: ignoring unsupported tagMAN_SUBDIR =' at line 1911, file docs/Doxyfile Warning: ignoring unsupported tag DOCBOOK_PROGRAMLISTING =' at line 1974, file docs/Doxyfile Warning: ignoring unsupported tagDIA_PATH =' at line 2183, file docs/Doxyfile Warning: ignoring unsupported tag DIAFILE_DIRS =' at line 2395, file docs/Doxyfile Warning: ignoring unsupported tagPLANTUML_JAR_PATH =' at line 2403, file docs/Doxyfile Warning: ignoring unsupported tag PLANTUML_CFG_FILE =' at line 2408, file docs/Doxyfile Warning: ignoring unsupported tagPLANTUML_INCLUDE_PATH =' at line 2413, file docs/Doxyfile warning: source docs/dot/ is not a readable file or directory... skipping. /home/macerab/software/libmemory-master/docs/CONTRIBUTING.md:79: warning: Illegal command mbeddedartistry as part of a .. block /home/macerab/software/libmemory-master/docs/CONTRIBUTING.md:326: warning: Illegal command mbeddedartistry as part of a .. block /home/macerab/software/libmemory-master/README.md:110: warning: Illegal command mbeddedartistry as part of a .. block

Steps to Reproduce

Please provide detailed steps for reproducing the issue.

  1. go to libmemory-master root
  2. run make

Failure Logs

Premake did not work

Detected OS: Linux. Using Premake binary: build/bin/Linux/premake5 Error: module 'build/modules/arch' not found: no field package.preload['build/modules/arch'] no file '/usr/local/share/lua/5.3/build/modules/arch.lua' no file '/usr/local/share/lua/5.3/build/modules/arch/init.lua' no file '/usr/local/lib/lua/5.3/build/modules/arch.lua' no file '/usr/local/lib/lua/5.3/build/modules/arch/init.lua' no file './build/modules/arch.lua' no file './build/modules/arch/init.lua' no file '/usr/local/lib/lua/5.3/build/modules/arch.so' no file '/usr/local/lib/lua/5.3/loadall.so' no file './build/modules/arch.so' no file '/home/macerab/software/libmemory-master/build/bin/Linux/build/modules/arch.so'

Linking libmemory_freertos ==== Building libmemory_freelist_UnitTests (debug_x86_64) ====

==== Building libmemory_freelist_UnitTests (debug_x86_64) ==== main.c aligned_malloc.c ../../test/src/aligned_malloc.c: In function ‘aligned_malloc_test’: ../../test/src/aligned_malloc.c:33:13: erreur: redefinition of ‘align’ for(size_t align = 2; align <= 8192; align = 2) ^ ../../test/src/aligned_malloc.c:31:9: note: previous definition of ‘align’ was here size_t align = 2; ^ ../../test/src/aligned_malloc.c:33:2: erreur: ‘for’ loop initial declarations are only allowed in C99 mode for(size_t align = 2; align <= 8192; align = 2) ^ ../../test/src/aligned_malloc.c:33:2: note: use option -std=c99 or -std=gnu99 to compile your code ../../test/src/aligned_malloc.c:43:13: erreur: redefinition of ‘align’ for(size_t align = 2; align <= 8192; align = 2) ^ ../../test/src/aligned_malloc.c:33:13: note: previous definition of ‘align’ was here for(size_t align = 2; align <= 8192; align = 2) ^ ../../test/src/aligned_malloc.c:43:2: erreur: ‘for’ loop initial declarations are only allowed in C99 mode for(size_t align = 2; align <= 8192; align *= 2) ^ make[2]: [obj/x86_64/debug/libmemory_freelist_UnitTests/aligned_malloc.o] Erreur 1 make[1]: [libmemory_freelist_UnitTests] Erreur 2 make[1] : on quitte le répertoire « /home/macerab/software/libmemory-master/build/gen » make: *** [build] Erreur 2

==== Building libmemory_freelist_UnitTests (debug_x86_64) ====

==== Building libmemory_freelist_UnitTests (debug_x86_64) ==== aligned_malloc.c malloc_freelist.c ../../test/src/malloc_freelist.c: In function ‘malloc_test’: ../../test/src/malloc_freelist.c:47:2: erreur: ‘for’ loop initial declarations are only allowed in C99 mode for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:47:2: note: use option -std=c99 or -std=gnu99 to compile your code ../../test/src/malloc_freelist.c:55:10: erreur: redefinition of ‘i’ for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:47:10: note: previous definition of ‘i’ was here for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:55:2: erreur: ‘for’ loop initial declarations are only allowed in C99 mode for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:61:10: erreur: redefinition of ‘i’ for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:55:10: note: previous definition of ‘i’ was here for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:61:2: erreur: ‘for’ loop initial declarations are only allowed in C99 mode for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:69:10: erreur: redefinition of ‘i’ for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:61:10: note: previous definition of ‘i’ was here for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ ../../test/src/malloc_freelist.c:69:2: erreur: ‘for’ loop initial declarations are only allowed in C99 mode for(int i = 0; i < ALLOCATION_TEST_COUNT; i++) ^ make[2]: [obj/x86_64/debug/libmemory_freelist_UnitTests/malloc_freelist.o] Erreur 1 make[1]: [libmemory_freelist_UnitTests] Erreur 2 make[1] : on quitte le répertoire « /home/macerab/software/libmemory-master/build/gen » make: *** [build] Erreur 2

==== Building libmemory_freelist_UnitTests (debug_x86_64) ====

==== Building libmemory_freelist_UnitTests (debug_x86_64) ==== malloc_freelist.c memory.c ../../test/support/memory.c:11:16: erreur: variably modified ‘mem_block’ at file scope static uint8_t mem_block[memblock_size]; ^ ../../test/support/memory.c:13:1: erreur: un élément de l'initialisation n'est pas une constante static const intptr_t mem_block_addr_end = mem_block_addr + memblock_size; ^ make[2]: [obj/x86_64/debug/libmemory_freelist_UnitTests/memory.o] Erreur 1 make[1]: [libmemory_freelist_UnitTests] Erreur 2 make[1] : on quitte le répertoire « /home/macerab/software/libmemory-master/build/gen » make: *** [build] Erreur 2

At linking time

Linking libmemory_freelist_UnitTests obj/x86_64/debug/libmemory_freelist_UnitTests/main.o: dans la fonction « main »: /home/macerab/software/libmemory-master/build/gen/../../test/main.c:24: référence indéfinie vers « cmocka_set_message_output » obj/x86_64/debug/libmemory_freelist_UnitTests/aligned_malloc.o: dans la fonction « aligned_malloc_test »: /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:25: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:36: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:37: référence indéfinie vers « _assert_in_range » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:38: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:46: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:47: référence indéfinie vers « _assert_in_range » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:48: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:54: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:58: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:62: référence indéfinie vers « _assert_true » obj/x86_64/debug/libmemory_freelist_UnitTests/aligned_malloc.o: dans la fonction « aligned_malloc_tests »: /home/macerab/software/libmemory-master/build/gen/../../test/src/aligned_malloc.c:69: référence indéfinie vers « _cmocka_run_group_tests » obj/x86_64/debug/libmemory_freelist_UnitTests/malloc_freelist.o: dans la fonction « malloc_test »: /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:30: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:38: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:39: référence indéfinie vers « _assert_in_range » /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:45: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:51: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:52: référence indéfinie vers « _assert_in_range » /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:65: référence indéfinie vers « _assert_true » /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:66: référence indéfinie vers « _assert_in_range » obj/x86_64/debug/libmemory_freelist_UnitTests/malloc_freelist.o: dans la fonction « malloc_tests »: /home/macerab/software/libmemory-master/build/gen/../../test/src/malloc_freelist.c:80: référence indéfinie vers « _cmocka_run_group_tests » collect2: erreur: ld a retourné 1 code d'état d'exécution make[2]: [../../buildresults/x86_64_debug/test/libmemory_freelist.bin] Erreur 1 make[1]: [libmemory_freelist_UnitTests] Erreur 2 make[1] : on quitte le répertoire « /home/macerab/software/libmemory-master/build/gen » make: *** [build] Erreur 2

phillipjohnston commented 6 years ago

I have received your issue and I will look into it when I have some time next week. I haven't tried the C99 flag with libmemory yet.

phillipjohnston commented 6 years ago

Hi @BastienMac, I am sorry for my neglect of this issue. I've been pulled away from my projects for many months, but I'm actively working on this now.

I didn't initially design this library with the explicit intent to support C99 - and as you can see the `for declaration is particularly ubiquitous. I will likely not get around to updating the tests at this time. However, I can update the build system so that building the tests is optional - only the tests seem to be failing.

As far as Premake goes, I have moved to meson/ninja and will also be moving away from CMocka. This has been working better for my needs and does not require me shipping with a binary, since it's much more easily accessible.