Skip to content

Duplicate values in 'add_values' are ignored, causing issues in some cases #7239

@PFiS1737

Description

@PFiS1737

Xmake Version

v3.0.6+20260104

Operating System Version and Architecture

Linux archlinux 6.18.5-2-cachyos

Describe Bug

I noticed that add_values seems to deduplicate the values passed to it, which can cause problems in some cases.

For example, when using Verilator, according to #3944, I need to pass flags like this:

add_values("verilator.flags", "--x-assign", "fast", "--x-initial", "fast")

However, the final command I get is:

/usr/bin/verilator ... --x-assign fast --x-initial src/hello.v

which results in the following error:

%Error: Unknown setting for --x-initial: 'src/hello.v'

In contrast, when I use

add_values("verilator.flags", "--x-assign", "unique", "--x-initial", "fast")

I get the correct command:

/usr/bin/verilator ... --x-assign unique --x-initial fast src/hello.v

Expected Behavior

For the first example above, the resulting command should be:

/usr/bin/verilator ... --x-assign fast --x-initial fast src/hello.v

Project Configuration

target("hello")
    add_rules("verilator.binary")
    set_toolchains("@verilator")
    add_files("src/*.v")
    add_files("src/*.cpp")
    add_values("verilator.flags", "--x-assign", "fast", "--x-initial", "fast")

Additional Information and Error Logs

$ xmake build --verbose
checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checking for nim ... no
checking for verilator ... /usr/bin/verilator
checking for verilator ... verilator
[  0%]: compiling.verilog src/main.v
/usr/bin/verilator --cc --make cmake --prefix hello --Mdir build/.gens/hello/linux/x86_64/release/rules/verilator --x-assign fast --x-initial src/main.v
%Error: Unknown setting for --x-initial: 'src/main.v'
        ... Suggest '0', 'fast', or 'unique'
        ... See the manual at https://verilator.org/verilator_doc.html?v=5.040 for more assistance.
%Error: verilator: No Input Verilog file specified on command line, see verilator --help for more information
        ... This fatal error may be caused by the earlier error(s); resolve those first.
error: execv(/usr/bin/verilator --cc --make cmake --prefix hello --Mdir build/.gens/hello/linux/x86_64/release/rules/verilator --x-assign fast --x-initial src/main.v) failed(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions