Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake update 2/3: lift platform restriction #758

Merged
merged 33 commits into from
Jul 21, 2021
Merged

CMake update 2/3: lift platform restriction #758

merged 33 commits into from
Jul 21, 2021

Conversation

lubgr
Copy link
Contributor

@lubgr lubgr commented Jul 20, 2021

Follow-up PR for the CMake modernization. This enables a CMake build for Unix-based systems. A particular emphasis lies on the seamless configuration of either statically or dynamically linked build artifacts: With these commands;

mkdir build && cd build
cmake path/to/chibi-source
make -j8
ctest

shared libraries are compiled, and the standard chibi executable is used to generate .c files from the stubs. With

mkdir build-static && cd build-static
cmake -D BUILD_SHARED_LIBS=OFF path/to/chibi-source
make -j8
ctest

a minimal bootstrap executable is built for the .stub to .c and the clib.c generation. This can be mixed with further common CMake options as -DCMAKE_BUILD_TYPE=Release or certain chibi options such as -DSEXP_USE_BOEHM=1.

There is not much else going on here. The main benefits of this are

  • CMake keeps the source directory completely clean. Generated files like install.h live in build directories, and multiple out-of-source build directory with different configurations can co-exist in different directories.
  • Ninja can be used instead of make if desired. IDE compatibility (Xcode, Visual Studio, Qt Creator, CLion etc) for those who prefer.
  • Chibi can very easily been integrated as a sub-repo of a project that is already configured with CMake. Having e.g. a git submodule in lib/chibi-scheme, the following setup
    add_subdirectory(libs/chibi-scheme)
    
    add_executable(my_great_app main.cpp)
    
    target_link_libraries(my_great_app
     PRIVATE
      chibi::libchibi-scheme)
    
    is sufficient to have the chibi library be compiled (static or dynamic according to the configuration) and the embedding application be compiled and linked with the appropriate flags.

lubgr added 27 commits July 20, 2021 15:37
With the module search path cleverly handled with different install.h
configurations, the genstatic script inserted absolute paths into the
generated clib.c file. This didn't fail on Windows CI as this is an
in-source build. For out-of-source builds, it's crucial that clib.c can
refer to both .c files in the source directory and those generated in
the build directory. As a fix, the genstatic invocation now uses the -I
flag.

This patch also improves the handling of include paths to find the .c.
files mentioned above by trimming down the scope of this property to
clib.c only. Also, there is no need to manually tell the preprocessor
where to look for generated .c, as they live relative to clib.c anyhow.
chibi/install.h is included in C source files, and providing a different
install.h upon actual installation is inconsistent and dangerous. When
working with a chibi executable within the build tree (i.e., not an
installed executable), the CHIBI_MODULE_PATH environment tweak can be
used to not always specify -I paths on the command line.
Copy link
Collaborator

@okuoku okuoku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ToDo:

CMakeLists.txt Outdated Show resolved Hide resolved
contrib/chibi-genstatic-helper.cmake Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
@lubgr
Copy link
Contributor Author

lubgr commented Jul 20, 2021

Sanitizer on CI

Yeah, sanitiser builds are interesting. This is what I get on MacOS for an ordinary startup - certainly some things that might be worth addressing. Should I raise an issue for this?

Sanitizer output
chibi-scheme/sexp.c:1476:28: runtime error: unsigned integer overflow: 1837648261714676624 * 16777619 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/sexp.c:1476:28 in 
chibi-scheme/sexp.c:1917:24: runtime error: negation of 1 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/sexp.c:1917:24 in 
chibi-scheme/sexp.c:2005:32: runtime error: negation of 1 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/sexp.c:2005:32 in 
chibi-scheme/vm.c:166:3: runtime error: store to misaligned address 0x000109661891 for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x000109661891: note: pointer points here
 00 00 00  16 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:166:3 in 
chibi-scheme/vm.c:1383:5: runtime error: load of misaligned address 0x000109661af1 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x000109661af1: note: pointer points here
 00 00 00  0f 60 1a 66 09 01 00 00  00 0f e0 51 65 09 01 00  00 00 39 0f 3e 04 00 00  00 00 00 00 4f
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1383:5 in 
chibi-scheme/vm.c:214:5: runtime error: store to misaligned address 0x0001096e2e23 for type 'sexp_sint_t' (aka 'long'), which requires 8 byte alignment
0x0001096e2e23: note: pointer points here
 00  00 00 0d 00 00 00 00 00  00 00 00 16 01 00 00 00  00 00 00 00 31 06 00 00  00 00 00 00 00 02 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:214:5 in 
chibi-scheme/vm.c:522:31: runtime error: negation of 2 cannot be represented in type 'sexp_uint_t' (aka 'unsigned long')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:522:31 in 
chibi-scheme/gc.c:269:45: runtime error: unsigned integer overflow: 0 - 1 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/gc.c:269:45 in 
chibi-scheme/vm.c:226:31: runtime error: negation of 9 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:226:31 in 
chibi-scheme/vm.c:1419:12: runtime error: load of misaligned address 0x00010972dc5a for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010972dc5a: note: pointer points here
 00 00  00 14 80 12 62 09 01 00  00 00 39 0f 3e 04 00 00  00 00 00 00 4f 00 00 00  00 00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1419:12 in 
chibi-scheme/vm.c:1437:33: runtime error: load of misaligned address 0x000109644b91 for type 'sexp_sint_t' (aka 'long'), which requires 8 byte alignment
0x000109644b91: note: pointer points here
 00 00 00  16 00 00 00 00 00 00 00  00 13 60 c3 6a 09 01 00  00 00 06 03 00 00 00 00  00 00 00 36 16
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1437:33 in 
chibi-scheme/vm.c:1412:5: runtime error: load of misaligned address 0x000109644b9a for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x000109644b9a: note: pointer points here
 00 00  00 13 60 c3 6a 09 01 00  00 00 06 03 00 00 00 00  00 00 00 36 16 02 00 00  00 00 00 00 00 0f
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1412:5 in 
chibi-scheme/vm.c:1271:9: runtime error: load of misaligned address 0x000109644ba3 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x000109644ba3: note: pointer points here
 00  00 00 06 03 00 00 00 00  00 00 00 36 16 02 00 00  00 00 00 00 00 0f c0 4b  78 09 01 00 00 00 13
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1271:9 in 
chibi-scheme/vm.c:1350:25: runtime error: load of misaligned address 0x00010974b06c for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010974b06c: note: pointer points here
  00 00 00 0a 20 98 62 09  01 00 00 00 4f 00 00 00  00 00 00 00 00 00 00 00  40 02 00 00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1350:25 in 
chibi-scheme/vm.c:1350:56: runtime error: load of misaligned address 0x00010974b06c for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010974b06c: note: pointer points here
  00 00 00 0a 20 98 62 09  01 00 00 00 4f 00 00 00  00 00 00 00 00 00 00 00  40 02 00 00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1350:56 in 
chibi-scheme/vm.c:1254:9: runtime error: load of misaligned address 0x000109644c2b for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x000109644c2b: note: pointer points here
 00  00 00 05 07 00 00 00 00  00 00 00 4f 00 00 00 00  00 00 00 00 00 00 00 00  0a 00 00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1254:9 in 
chibi-scheme/vm.c:1431:30: runtime error: load of misaligned address 0x000109661c16 for type 'sexp_sint_t' (aka 'long'), which requires 8 byte alignment
0x000109661c16: note: pointer points here
 00 00 00 15 03 00  00 00 00 00 00 00 1b 26  01 00 00 00 00 00 00 00  03 00 00 00 00 00 00 00  20 1b
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1431:30 in 
chibi-scheme/vm.c:1448:5: runtime error: load of misaligned address 0x00010963a05a for type 'sexp_sint_t' (aka 'long'), which requires 8 byte alignment
0x00010963a05a: note: pointer points here
 00 00  1b 18 00 00 00 00 00 00  00 00 0f 05 00 00 00 00  00 00 00 15 03 00 00 00  00 00 00 00 1b 16
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1448:5 in 
chibi-scheme/vm.c:1578:13: runtime error: load of misaligned address 0x00010963a092 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010963a092: note: pointer points here
 00 00  1b 26 01 00 00 00 00 00  00 00 07 00 00 00 00 00  00 00 a0 9c 63 09 01 00  00 00 05 07 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1578:13 in 
chibi-scheme/vm.c:1578:13: runtime error: load of misaligned address 0x00010963a09a for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010963a09a: note: pointer points here
 00 00  00 00 07 00 00 00 00 00  00 00 a0 9c 63 09 01 00  00 00 05 07 00 00 00 00  00 00 00 4f 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1578:13 in 
chibi-scheme/vm.c:1578:13: runtime error: load of misaligned address 0x00010963a0a2 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010963a0a2: note: pointer points here
 00 00  00 00 a0 9c 63 09 01 00  00 00 05 07 00 00 00 00  00 00 00 4f 00 00 00 00  00 00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1578:13 in 
chibi-scheme/vm.c:1443:20: runtime error: load of misaligned address 0x0001097849cd for type 'sexp_sint_t' (aka 'long'), which requires 8 byte alignment
0x0001097849cd: note: pointer points here
 00 00 3a 17 fb ff ff  ff ff ff ff ff 0f 3e 02  00 00 00 00 00 00 0f 3e  04 00 00 00 00 00 00 0f  05
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1443:20 in 
chibi-scheme/vm.c:1373:13: runtime error: load of misaligned address 0x0001096c7e5c for type 'sexp_sint_t' (aka 'long'), which requires 8 byte alignment
0x0001096c7e5c: note: pointer points here
  00 37 2a 0d 1a 00 00 00  00 00 00 00 0f 3e 04 00  00 00 00 00 00 0e ac 00  00 00 00 00 00 00 16 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1373:13 in 
chibi-scheme/vm.c:1343:25: runtime error: load of misaligned address 0x0001097844e4 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x0001097844e4: note: pointer points here
  00 00 00 09 40 97 62 09  01 00 00 00 0f 3e 04 00  00 00 00 00 00 0f 09 00  00 00 00 00 00 00 27 16
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1343:25 in 
chibi-scheme/vm.c:1343:56: runtime error: load of misaligned address 0x0001097844e4 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x0001097844e4: note: pointer points here
  00 00 00 09 40 97 62 09  01 00 00 00 0f 3e 04 00  00 00 00 00 00 0f 09 00  00 00 00 00 00 00 27 16
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1343:56 in 
chibi-scheme/vm.c:1639:39: runtime error: load of misaligned address 0x000109783a44 for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x000109783a44: note: pointer points here
  00 00 00 32 16 00 00 00  00 00 00 00 03 00 00 00  00 00 00 00 0f 3e 04 00  00 00 00 00 00 11 16 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1639:39 in 
chibi-scheme/vm.c:1643:5: runtime error: load of misaligned address 0x000109783a4c for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x000109783a4c: note: pointer points here
  00 00 00 00 03 00 00 00  00 00 00 00 0f 3e 04 00  00 00 00 00 00 11 16 00  00 00 00 00 00 00 00 4f
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1643:5 in 
chibi-scheme/vm.c:1329:25: runtime error: load of misaligned address 0x000109655151 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x000109655151: note: pointer points here
 00 00 00  07 60 c9 62 09 01 00 00  00 14 40 0f 62 09 01 00  00 00 37 0f 3e 04 00 00  00 00 00 00 0f
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1329:25 in 
chibi-scheme/vm.c:1329:56: runtime error: load of misaligned address 0x000109655151 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x000109655151: note: pointer points here
 00 00 00  07 60 c9 62 09 01 00 00  00 14 40 0f 62 09 01 00  00 00 37 0f 3e 04 00 00  00 00 00 00 0f
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1329:56 in 
chibi-scheme/vm.c:1379:11: runtime error: load of misaligned address 0x000109654f15 for type 'sexp_sint_t' (aka 'long'), which requires 8 byte alignment
0x000109654f15: note: pointer points here
 00 00 00 0e 11 00 00  00 00 00 00 00 16 01 00  00 00 00 00 00 00 18 00  00 00 00 00 00 00 00 16  00
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1379:11 in 
chibi-scheme/vm.c:1357:25: runtime error: load of misaligned address 0x000109654f5d for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x000109654f5d: note: pointer points here
 00 00 00 0b 20 72 62  09 01 00 00 00 4f 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1357:25 in 
chibi-scheme/vm.c:1357:56: runtime error: load of misaligned address 0x000109654f5d for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x000109654f5d: note: pointer points here
 00 00 00 0b 20 72 62  09 01 00 00 00 4f 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1357:56 in 
chibi-scheme/vm.c:1616:26: runtime error: load of misaligned address 0x0001096c774c for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x0001096c774c: note: pointer points here
  00 00 00 2f 06 00 00 00  00 00 00 00 0d 35 00 00  00 00 00 00 00 18 02 00  00 00 00 00 00 00 0f 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1616:26 in 
chibi-scheme/vm.c:1336:25: runtime error: load of misaligned address 0x0001096513d6 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x0001096513d6: note: pointer points here
 00 00 00 08 e0 6e  62 09 01 00 00 00 0d 47  00 00 00 00 00 00 00 16  00 00 00 00 00 00 00 00  13 60
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1336:25 in 
chibi-scheme/vm.c:1336:56: runtime error: load of misaligned address 0x0001096513d6 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x0001096513d6: note: pointer points here
 00 00 00 08 e0 6e  62 09 01 00 00 00 0d 47  00 00 00 00 00 00 00 16  00 00 00 00 00 00 00 00  13 60
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1336:56 in 
chibi-scheme/vm.c:1632:39: runtime error: load of misaligned address 0x0001096e30b5 for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x0001096e30b5: note: pointer points here
 00 00 00 31 06 00 00  00 00 00 00 00 02 00 00  00 00 00 00 00 16 00 00  00 00 00 00 00 00 32 06  00
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1632:39 in 
chibi-scheme/vm.c:1634:13: runtime error: load of misaligned address 0x0001096e30bd for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x0001096e30bd: note: pointer points here
 00 00 00 00 02 00 00  00 00 00 00 00 16 00 00  00 00 00 00 00 00 32 06  00 00 00 00 00 00 00 02  00
             ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1634:13 in 
chibi-scheme/vm.c:1399:9: runtime error: load of misaligned address 0x00010964fcb9 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010964fcb9: note: pointer points here
 00 00 00  12 c0 ee 64 09 01 00 00  00 05 03 00 00 00 00 00  00 00 4f 00 00 00 00 00  00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1399:9 in 
chibi-scheme/sexp.c:3645:39: runtime error: division by zero
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/sexp.c:3645:39 in 
chibi-scheme/sexp.c:3647:39: runtime error: division by zero
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/sexp.c:3647:39 in 
chibi-scheme/vm.c:1402:11: runtime error: load of misaligned address 0x00010970f443 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010970f443: note: pointer points here
 00  00 00 12 20 6e 6c 09 01  00 00 00 06 05 00 00 00  00 00 00 00 0d 37 00 00  00 00 00 00 00 18 01
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1402:11 in 
chibi-scheme/vm.c:1402:11: runtime error: load of misaligned address 0x00010970f443 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010970f443: note: pointer points here
 00  00 00 12 20 6e 6c 09 01  00 00 00 06 05 00 00 00  00 00 00 00 0d 37 00 00  00 00 00 00 00 18 01
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1402:11 in 
chibi-scheme/vm.c:1403:35: runtime error: load of misaligned address 0x00010970f443 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010970f443: note: pointer points here
 00  00 00 12 20 6e 6c 09 01  00 00 00 06 05 00 00 00  00 00 00 00 0d 37 00 00  00 00 00 00 00 18 01
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1403:35 in 
chibi-scheme/vm.c:1403:70: runtime error: load of misaligned address 0x00010970f443 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010970f443: note: pointer points here
 00  00 00 12 20 6e 6c 09 01  00 00 00 06 05 00 00 00  00 00 00 00 0d 37 00 00  00 00 00 00 00 18 01
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1403:70 in 
chibi-scheme/vm.c:1404:27: runtime error: store to misaligned address 0x00010970f443 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010970f443: note: pointer points here
 00  00 00 12 20 6e 6c 09 01  00 00 00 06 05 00 00 00  00 00 00 00 0d 37 00 00  00 00 00 00 00 18 01
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1404:27 in 
chibi-scheme/vm.c:1406:11: runtime error: load of misaligned address 0x00010970f443 for type 'sexp' (aka 'struct sexp_struct *'), which requires 8 byte alignment
0x00010970f443: note: pointer points here
 00  00 00 12 20 3a 65 09 01  00 00 00 06 05 00 00 00  00 00 00 00 0d 37 00 00  00 00 00 00 00 18 01
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1406:11 in 
chibi-scheme/sexp.c:2862:15: runtime error: signed integer overflow: 2288728493826497114 * 10 cannot be represented in type 'long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/sexp.c:2862:15 in 
chibi-scheme/vm.c:1624:5: runtime error: load of misaligned address 0x00010979fb39 for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x00010979fb39: note: pointer points here
 00 00 00  00 30 00 00 00 00 00 00  00 4f 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1624:5 in 
chibi-scheme/vm.c:1624:5: runtime error: load of misaligned address 0x00010979fb31 for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x00010979fb31: note: pointer points here
 00 00 00  30 2a 00 00 00 00 00 00  00 30 00 00 00 00 00 00  00 4f 00 00 00 00 00 00  00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1624:5 in 
chibi-scheme/vm.c:1626:13: runtime error: load of misaligned address 0x00010979fb39 for type 'sexp_uint_t' (aka 'unsigned long'), which requires 8 byte alignment
0x00010979fb39: note: pointer points here
 00 00 00  00 30 00 00 00 00 00 00  00 4f 00 00 00 00 00 00  00 00 00 00 00 00 00 00  00 00 00 00 00
              ^ 
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/vm.c:1626:13 in 
chibi-scheme/bignum.c:219:16: runtime error: unsigned integer overflow: 18446744073709551610 + 6 cannot be represented in type 'unsigned long'
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/bignum.c:219:16 in 
chibi-scheme/sexp.c:2556:16: runtime error: implicit conversion from type 'int' of value 195 (32-bit, signed) to type 'char' changed the value to -61 (8-bit, signed)
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior chibi-scheme/sexp.c:2556:16 

@okuoku
Copy link
Collaborator

okuoku commented Jul 21, 2021

Should I raise an issue for this?

I'd like to defer to @ashinn .

Overflows: In other Schemes, Chicken uses -fwrapv for example. So that can be by-design. I personally prefer trying to follow C standard behaviour though.

Unaligned access: I assume these are portability issue. ... but it's true it won't cause any issue on modern systems aside microcontrollers.

@ashinn
Copy link
Owner

ashinn commented Jul 21, 2021

Regarding the unaligned read warnings, this can be removed by setting SEXP_USE_ALIGNED_BYTECODE. It defaults to true on platforms where this is required (arm, sparc, etc.), but will be false on x86 where these aren't really valid warnings.

@okuoku, I'll leave merging this to you when ready.

@okuoku okuoku self-assigned this Jul 21, 2021
@lubgr
Copy link
Contributor Author

lubgr commented Jul 21, 2021

Regarding the unaligned read warnings, this can be removed by setting SEXP_USE_ALIGNED_BYTECODE

That's true, no such warnings with this flag. I wasn't aware that x86 has fewer alignment rules compared to other architectures. Could you point me to some reference where this is explained?

I'll raise an issue with the remaining warnings; this might be worth having a look at.

Copy link
Collaborator

@okuoku okuoku left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, waiting for the CI.

@okuoku okuoku merged commit 879c16c into ashinn:master Jul 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants