Skip to content

Syscall cmake deps not correctly set when modifying existing syscall #96881

@mark-inderhees

Description

@mark-inderhees

Describe the bug

The current cmake logic for syscalls makes an incorrect assumption, in CMakeLists.txt

  # On other OS'es, modifying a file is reflected on the folder timestamp and hence detected
  # when using depend on directory level.

This is not correct. If I modify an existing file, the parent directory timestamp is not updated. The parent directory is only updated on file adds and removes. This is tricky to reproduce, as git checkouts and patch applies end up doing file adds even when just modifying a few lines. To reproduce, have to do a "true" file edit.

Regression

  • This is a regression.

Steps to reproduce

  1. Apply this patch
    1a. save to file repo.patch
diff --git a/drivers/gpio/gpio_nrfx.c b/drivers/gpio/gpio_nrfx.c
index 6ccb378e161..fb4828674a8 100644
--- a/drivers/gpio/gpio_nrfx.c
+++ b/drivers/gpio/gpio_nrfx.c
@@ -361,8 +361,9 @@ static int gpio_nrfx_port_clear_bits_raw(const struct device *port,
 }
 
 static int gpio_nrfx_port_toggle_bits(const struct device *port,
-                                     gpio_port_pins_t mask)
+                                     gpio_port_pins_t mask, uint32_t foo)
 {
+       (void)foo;
        NRF_GPIO_Type *reg = get_port_cfg(port)->port;
        const uint32_t value = nrf_gpio_port_out_read(reg) ^ mask;
        const uint32_t set_mask = value & mask;
diff --git a/include/zephyr/drivers/gpio.h b/include/zephyr/drivers/gpio.h
index 33962528136..d12bc1e8812 100644
--- a/include/zephyr/drivers/gpio.h
+++ b/include/zephyr/drivers/gpio.h
@@ -824,7 +824,7 @@ __subsystem struct gpio_driver_api {
        int (*port_clear_bits_raw)(const struct device *port,
                                   gpio_port_pins_t pins);
        int (*port_toggle_bits)(const struct device *port,
-                               gpio_port_pins_t pins);
+                               gpio_port_pins_t pins, uint32_t foo);
        int (*pin_interrupt_configure)(const struct device *port,
                                       gpio_pin_t pin,
                                       enum gpio_int_mode mode,
@@ -1491,10 +1491,10 @@ static inline int gpio_port_clear_bits(const struct device *port,
  * @retval -EWOULDBLOCK if operation would block.
  */
 __syscall int gpio_port_toggle_bits(const struct device *port,
-                                   gpio_port_pins_t pins);
+                                   gpio_port_pins_t pins, uint32_t foo);
 
 static inline int z_impl_gpio_port_toggle_bits(const struct device *port,
-                                              gpio_port_pins_t pins)
+                                              gpio_port_pins_t pins, uint32_t foo)
 {
        const struct gpio_driver_api *api =
                (const struct gpio_driver_api *)port->api;
@@ -1502,7 +1502,7 @@ static inline int z_impl_gpio_port_toggle_bits(const struct device *port,
 
        SYS_PORT_TRACING_FUNC_ENTER(gpio_port, toggle_bits, port, pins);
 
-       ret = api->port_toggle_bits(port, pins);
+       ret = api->port_toggle_bits(port, pins, foo);
        SYS_PORT_TRACING_FUNC_EXIT(gpio_port, toggle_bits, port, ret);
        return ret;
 }
@@ -1739,7 +1739,7 @@ static inline int gpio_pin_toggle(const struct device *port, gpio_pin_t pin)
        __ASSERT((cfg->port_pin_mask & (gpio_port_pins_t)BIT(pin)) != 0U,
                 "Unsupported pin");
 
-       return gpio_port_toggle_bits(port, (gpio_port_pins_t)BIT(pin));
+       return gpio_port_toggle_bits(port, (gpio_port_pins_t)BIT(pin), 1);
 }
 
 /**

1b. Apply the patch git apply repo.patch
2. Cache the files to tmp

cp drivers/gpio/gpio_nrfx.c /tmp/gpio_nrfx.c
cp include/zephyr/drivers/gpio.h /tmp/gpio.h
  1. Restore working directory
git restore drivers/gpio/gpio_nrfx.c
git restore include/zephyr/drivers/gpio.h
  1. Do pristine build of blinky west build -b nrf5340dk/nrf5340/cpuapp samples/basic/blinky -p always
  2. Copy in changes for "true" edit
cp /tmp/gpio_nrfx.c drivers/gpio/gpio_nrfx.c
cp /tmp/gpio.h include/zephyr/drivers/gpio.h
  1. Do incremental build of blinky, see build failure west build -b nrf5340dk/nrf5340/cpuapp samples/basic/blinky
error: conflicting types for 'z_impl_gpio_port_toggle_bits'
  1. "fix" the error by touching the parent directory touch include/zephyr/drivers
  2. See that fix works by successfully doing an incremental build west build -b nrf5340dk/nrf5340/cpuapp samples/basic/blinky

Relevant log output

Impact

Annoyance – Minor irritation; no significant impact on usability or functionality.

Environment

Linux
Hash ec72295 (recent main)

Additional Context

No response

Metadata

Metadata

Assignees

Labels

area: Build SystembugThe issue is a bug, or the PR is fixing a bug

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions