2566 Commits

Author SHA1 Message Date
Takatoshi Kondo
eba6304a3a
Merge pull request #1129 from redboltz/update_c_602
Updated the version to 6.0.2 (C)
c-6.0.2
2024-06-24 15:56:53 +09:00
Takatoshi Kondo
ef0927a6f0 Updated the version to 6.0.2 (C) 2024-06-24 15:30:56 +09:00
Takatoshi Kondo
bf2504e7bb
Merge pull request #1125 from otegami/fix-ignored-includedir
Fix header file installation to respect `CMAKE_INSTALL_INCLUDEDIR`
2024-06-24 15:28:45 +09:00
otegami
724d1aad39 Fix header file installation paths to respect CMAKE_INSTALL_INCLUDEDIR
Previously, header files were installed uniformly under the include directory, ignoring the specified paths.
This change ensures header files are installed in the appropriate directories under `CMAKE_INSTALL_INCLUDEDIR`.
2024-06-12 20:22:02 +08:00
Takatoshi Kondo
a5c8a2c845
Merge pull request #1121 from otegami/support-absolute-path-for-pkg-config
Support absolute path for CMAKE_INSTALL_*DIR
2024-05-14 16:01:23 +09:00
otegami
4e027b72de Support absolute path for CMAKE_INSTALL_*DIR
Issue

When `CMAKE_INSTALL_LIBDIR` and `CMAKE_INSTALL_INCLUDEDIR` are set to absolute paths, the `msgpack-c.pc` file generated by CMake improperly configures `libdir` and `includedir`. This leads to incorrect paths that prevent the compiler from locating necessary header and library files.

How to reproduce

Build and install `msgpack-c`.

```console
% cmake -S . -B ../msgpack-c.build -DCMAKE_INSTALL_LIBDIR=/tmp/local/lib -DCMAKE_INSTALL_INCLUDEDIR=/tmp/local/include
% cmake --build ../msgpack-c.build
% sudo cmake --install ../msgpack-c.build
```

Compile `example/simple_c.c` using installed msgpack-c. The following error happens because the linker cannot find paths provided by pkg-config.

```console
% export PKG_CONFIG_PATH=/tmp/local/lib/pkgconfig:$PKG_CONFIG_PATH
% gcc -o simple_c example/simple_c.c $(pkg-config --cflags --libs msgpack-c)
/usr/bin/ld: cannot find -lmsgpack-c: No such file or directory
collect2: error: ld returned 1 exit status
```

Expected

Successfully compile `example/simple_c.c` using installed msgpack-c. We can execute `simple_c` like the following.

```console
% gcc -o simple_c example/simple_c.c $(pkg-config --cflags --libs msgpack-c)
% ./simple_c
93 01 c3 a7 65 78 61 6d 70 6c 65
[1, true, "example"]
```

Explain the problem in detail

The generated `msgpack-c.pc` file does not handle absolute paths correctly. Here is the result of the incorrect configuration in `How to reproduce` section. In the following `msgpack-c.pc` file, `libdir` and `includedir` are showing unrecognized paths, leading to incorrect paths.

```console
% cat /tmp/local/lib/pkgconfig/msgpack-c.pc
prefix=/usr/local
exec_prefix=/usr/local
libdir=${prefix}//tmp/local/lib <- Here the path is wrong. We expected `/tmp/local/lib`
includedir=${prefix}//tmp/local/include <- Here the path is wrong. We expected `/tmp/local/include`

Name: MessagePack
Description: Binary-based efficient object serialization library
Version: 6.0.1
Libs: -L${libdir} -lmsgpack-c
Cflags: -I${includedir}
```

Solution

Modify the `CMakeLists.txt` file to ensure that `libdir` and `includedir` use absolute paths. This change addresses the issue by providing correct paths to the compiler and linker.
2024-05-12 21:38:35 +08:00
Takatoshi Kondo
c31fafbcd1
Merge pull request #1119 from otegami/support-relative-path-for-pkg-config
Support relative path for CMAKE_INSTALL_*DIR
2024-04-26 13:34:22 +09:00
otegami
68cc50a3de Support relative path for CMAKE_INSTALL_*DIR
When `CMAKE_INSTALL_LIBDIR` and `CMAKE_INSTALL_INCLUDEDIR` are set to relative paths, the `msgpack-c.pc` file generated by CMake improperly configures `libdir` and `includedir`. This leads to incorrect paths that prevent the compiler from locating necessary header and library files.

Build and install `msgpack-c`.

```console
% git switch -c c_master
% cmake -S . -B ../msgpack-c.build -DCMAKE_INSTALL_PREFIX=/tmp/local -DCMAKE_INSTALL_LIBDIR=lib-relative -DCMAKE_INSTALL_INCLUDEDIR=include-relative
% cmake --build ../msgpack-c.build
% cmake --install ../msgpack-c.build/
```

Compile `example/simple_c.c` using installed msgpack-c.
The following error happens because the linker cannot find paths provided by pkg-config.

```console
% export PKG_CONFIG_PATH=/usr/local/lib-relative/pkgconfig:$PKG_CONFIG_PATH
% gcc -o simple_c example/simple_c.c $(pkg-config --cflags --libs msgpack-c)
/usr/bin/ld: cannot find -lmsgpack-c: No such file or directory
collect2: error: ld returned 1 exit status
```

Successly compile `example/simple_c.c` using install msgpack-c.
We can execute `simple_c.c` like the following.

```console
% gcc -o simple_c example/simple_c.c $(pkg-config --cflags --libs msgpack-c)
% ./simple_c
93 01 c3 a7 65 78 61 6d 70 6c 65
[1, true, "example"]
```

The generated `msgpack-c.pc` file does not handle relative paths correctly. Here is the result of the incorrect configuration in How to reproduce section.
In the following `msgpack-c.pc` file, `libdir` and `includedir` are relative to the current directory, leading to incorrect paths.

```console
cat ../msgpack-c.build/msgpack-c.pc
prefix=/tmp/local
exec_prefix=/tmp/local
libdir=lib-relative
includedir=include-relative

Name: MessagePack
Description: Binary-based efficient object serialization library
Version: 6.0.1
Libs: -L${libdir} -lmsgpack-c
Cflags: -I${includedir}
```

Modify the `msgpack-c.pc.in` file to ensure that `libdir` and `includedir` use absolute paths by prefixing them with ${prefix}/. This change addresses the issue by providing correct paths to the compiler and linker.
2024-04-26 12:21:26 +08:00
Takatoshi Kondo
9f37918bb5
Merge pull request #1120 from redboltz/fix_osx_ci
Removed invalid ctest option `r`.
2024-04-26 13:02:40 +09:00
Takatoshi Kondo
b8b54a2fef Updated gtest install methond on macos. 2024-04-26 12:29:23 +09:00
Takatoshi Kondo
f2c1991ede Removed invalid ctest option r. 2024-04-26 12:19:06 +09:00
Takatoshi Kondo
5ab83b10b4
Merge pull request #1114 from redboltz/update_to_601_c
Update the version to 6.0.1.
c-6.0.1
2024-04-02 13:33:35 +09:00
Takatoshi Kondo
9785991158 Update the version to 6.0.1. 2024-04-02 12:29:17 +09:00
Takatoshi Kondo
68d085aa45
Merge pull request #1108 from Zopolis4/gnuinstalldirt
Use GNUInstallDirs to set installation directories
2024-03-07 19:32:11 +09:00
Zopolis4
d1af4a3cdb
Use GNUInstallDirs to set installation directories 2024-03-07 17:57:01 +11:00
Takatoshi Kondo
5f287d1361
Merge pull request #1109 from Zopolis4/appveyedc
Fix appveyor for c_master
2024-03-07 15:53:56 +09:00
Zopolis4
76d768c5a4
Update zlib to 1.3.1 in appveyor.yml 2024-03-07 15:08:41 +11:00
Takatoshi Kondo
37744bd6a8
Merge pull request #1097 from dundargoc/cmake-version
Bump minimum cmake version to 3.5 to avoid deprecation warning
2023-11-09 19:25:10 +09:00
dundargoc
8957d6ec07 Bump minimum cmake version to 3.5 to avoid deprecation warning
Building msgpack gives currently gives the following warning:
"CMake Deprecation Warning at CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 3.5 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions."

Reuse same solution as fc18087cdfaadec0b905643f93950387e797da08 as the
policy CMP0060 introduced in cmake 3.3 causes problems with when linking
for 32-bit otherwise.
2023-10-23 20:51:18 +02:00
Takatoshi Kondo
3a41b24ff2
Merge pull request #1091 from redboltz/update_zlib_for_ci_c
Updated zlib for CI.
2023-08-30 00:00:35 +09:00
Takatoshi Kondo
d03a9b91f3 Updated zlib for CI. 2023-08-29 23:31:35 +09:00
Takatoshi Kondo
366f06d4ac
Merge pull request #1069 from redboltz/fix_1066
Fix #1066.
2023-05-10 13:08:09 +09:00
Takatoshi Kondo
fe4312c427 Fix #1066. 2023-05-10 12:19:20 +09:00
Takatoshi Kondo
cd67366b7f
Merge pull request #1060 from ericvw/cmake-respect-prefx-at-install
cmake: Respect --prefix for headers during cmake --install
2023-04-14 18:19:57 +09:00
Eric N. Vander Weele
80f60009f5 cmake: Respect --prefix for headers during cmake --install
Removing CMAKE_INSTALL_PREFIX allows for `cmake --install <build-dir>
--prefix=<installation-prefix>` to install headers at
`<installation-prefix>/include` at install time.

When CMAKE_INSTALL_PREFIX is present in `INSTALL()`, it is hard-coded
during configuration (e.g., `cmake -S .`), which disallows it from being
set at install time.
2023-04-12 09:22:22 -04:00
Takatoshi Kondo
4fd5056ea5
Merge pull request #1061 from ericvw/ci-linux-ubuntu-latest
ci: Use ubuntu-latest for CI on Linux
2023-04-12 12:03:25 +09:00
Eric N. Vander Weele
7fc51afd59 ci: Use ubuntu-latest for CI on Linux
Ubuntu 18.04 is deprecated on GitHub Actions. Additionally:

- Install 'clang' to get the latest clang toolchain.
    - Use -gdwarf-4 so Valgrind understands the debug information.
- Install latest version of gtest (v1.13.0).
- Show compile and link commands when building.
- `cat` Valgrind output on error.
2023-04-11 15:39:50 -04:00
Takatoshi Kondo
8160ede5e2 Update README.md. c-6.0.0 2023-03-04 22:43:04 +09:00
Takatoshi Kondo
6e8503f1c0
Merge pull request #1055 from dundargoc/build/only-c
Explicitly specify the project is a C project if tests aren't used.
2023-03-04 22:39:01 +09:00
dundargoc
2f543923d2 Explicitly specify the project is a C project.
CMake assumes the default project uses both C and C++, and therefore
will fail if both a C and a C++ compiler isn't found. This essentially
blocks pure C projects from using msgpack-c if they also don't have a
C++ compiler.

Just specifying that the project is "C" isn't possible though, as the
test themselves use C++. The workaround here is that we specify the
project needs both a C and C++ compiler if tests are used, but only a C
compiler if the tests aren't used.
2023-03-04 13:41:42 +01:00
Takatoshi Kondo
b3de6f83cb
Merge pull request #1053 from redboltz/unify_project_name_c
Unify all package related names to msgpack-c.
2023-03-04 21:35:08 +09:00
Takatoshi Kondo
01f3d24fee Unify all package related names to msgpack-c.
Update the version to 6.0.0.
2023-02-28 10:49:13 +09:00
Takatoshi Kondo
551308ae10
Merge pull request #1049 from redboltz/fix_makedist.sh
Fixed cmake config name.
c-5.0.0
2023-01-10 21:41:34 +09:00
Takatoshi Kondo
f2c446799c Fixed cmake config name. 2023-01-10 20:06:01 +09:00
Takatoshi Kondo
c2430635f9
Merge pull request #1047 from redboltz/update_to_500_c
Updated the version to 5.0.0.
2023-01-10 19:58:15 +09:00
Takatoshi Kondo
bffd3f2091 Updated the version to 5.0.0. 2023-01-10 18:50:20 +09:00
Takatoshi Kondo
076b5ed7fd
Merge pull request #1044 from traversaro/patch-1
Change CMake package name of C library to msgpackc
2023-01-10 18:32:20 +09:00
Silvio Traversaro
52fa74804c
Update CMakeLists.txt 2023-01-10 10:02:33 +01:00
Silvio Traversaro
5ae6077234
Update appveyor.yml 2023-01-07 14:40:24 +01:00
Silvio Traversaro
43de525dc7
Update zlib used in AppVeyor to 1.2.13 2023-01-07 13:35:33 +01:00
Silvio Traversaro
f7961b798b
Change CMake package name to msgpackc 2023-01-05 14:59:10 +01:00
Silvio Traversaro
5cada9eb27
Update and rename msgpack-config.cmake.in to msgpackc-config.cmake.in 2023-01-05 14:55:45 +01:00
Silvio Traversaro
ce42436f20
Change CMake package name to msgpackc 2023-01-05 14:55:10 +01:00
Takatoshi Kondo
c3df1bb26e
Merge pull request #1023 from redboltz/add_sanitizer
Added additional address sanitizer for CI.
2022-06-05 21:15:26 +09:00
Takatoshi Kondo
63d3b093f0 Updated appveyor zlib version. 2022-06-05 20:35:54 +09:00
Takatoshi Kondo
8b57d2caf9 Added additional address sanitizer for CI.
Except install, and except SHARED=OFF.
2022-06-05 20:30:14 +09:00
Takatoshi Kondo
a9a48cea3a
Merge pull request #976 from redboltz/update_to_c_4
Updated the version to 4.0.0.
c-4.0.0
2021-09-01 11:10:58 +09:00
Takatoshi Kondo
e96853a946 Updated the version to 4.0.0. 2021-09-01 10:50:27 +09:00
Takatoshi Kondo
2ebe884c0e
Merge pull request #962 from jrtc27/c-cheri
Support building for CHERI/Morello
2021-08-17 14:20:42 +09:00
Jessica Clarke
823caa8d8c Increase portability by masking rather than dividing and multiplying pointers
If (u)intptr_t exist, the only guarantee provided by the C standard is
that you can cast a pointer to one and back. No claims are made about
what that injective pointer-to-integer mapping is, nor the surjective
reverse integer-to-pointer mapping; for example, nowhere is it specified
that, given a char *p, p + 1 == (char *)((uintptr_t)p + 1), although no
sensible implementation would make that not the case (provided p is a
valid strictly in bounds pointer).

With real pointers, taking them out of bounds (other than the one
exception that is a one-past-the-end pointer) of their corresponding
allocation is UB. Whilst the semantics of arithmetic on uintptr_t is not
specified when cast back to a pointer, compilers already assume that
uintptr_t arithmetic does not go out of bounds (or, put another way,
that the result always ends up pointing to the same allocation) and
their alias analysis-based optimisations already assume this. CHERI, and
Arm's Morello, implement C language pointers with hardware capabilities,
which are unforgeable pointers with bounds and permissions. In order to
only double rather than quadruple the size of pointers, CHERI exploits
C's requirement that pointers not be taken out of bounds, and compresses
these bounds using a floating-point-like representation. The important
implication of this for most software is that if a capability, i.e. C
pointer in CHERI C, is taken too far out of bounds (where "too far" is
proportional to the size of the allocation) it can no longer be
represented and thus is invalidated, meaning it will trap on a later
dereference. This also extends to (u)intptr_t, which are also
implemented as capabilities, since if it were just a plain integer then
casting a pointer to (u)intptr_t would lose the metadata and break the
ability to cast back to a pointer.

Whilst the composition of dividing a pointer and then multiplying it
again has a somewhat sensible interpretation of rounding it down (even
though technically no such guarantees are made by the spec), the
individual operations do not, and the division is highly likely to take
the pointer far out of bounds of its allocation and, on CHERI, result in
it being unrepresentable and thus invalidated. Instead, we can perform a
more standard bitwise AND with a mask to clear the low bits, exploiting
the fact that alignments are powers of two; note that technically the
rounding up variant of this does take the pointer out of bounds slightly
and, whilst there are other ways to write such code that avoid doing so,
they are more cumbersome, and this code does not need to worry about
that.
2021-08-07 00:19:46 +01:00