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

Blink Example Fails #285

Closed
playduck opened this issue Dec 1, 2024 · 4 comments
Closed

Blink Example Fails #285

playduck opened this issue Dec 1, 2024 · 4 comments

Comments

@playduck
Copy link

playduck commented Dec 1, 2024

Trying to build the blink.c example (or any other example I've tried) as described in the wiki doesn't work:

% pipelinec examples/blink.c


██████╗ ██╗██████╗ ███████╗██╗     ██╗███╗   ██╗███████╗ ██████╗
██╔══██╗██║██╔══██╗██╔════╝██║     ██║████╗  ██║██╔════╝██╔════╝
██████╔╝██║██████╔╝█████╗  ██║     ██║██╔██╗ ██║█████╗  ██║
██╔═══╝ ██║██╔═══╝ ██╔══╝  ██║     ██║██║╚██╗██║██╔══╝  ██║
██║     ██║██║     ███████╗███████╗██║██║ ╚████║███████╗╚██████╗
╚═╝     ╚═╝╚═╝     ╚══════╝╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝ ╚═════╝

Output directory: /.../PipelineC/pipelinec_output_blink.c_52928
================== Parsing C Code to Logical Hierarchy ================================
Parsing: /.../PipelineC/examples/blink.c
Preprocessing file...
/.../PipelineC/examples/blink.c:1:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
    1 | #include "uintN_t.h"  // uintN_t types for any N
      |                       ^
      |                       //
1 warning generated.
Parsing C syntax...
pycparser says you messed up: /.../PipelineC/include/uintN_t.h:2:1: before: /

I'm assuming this project uses Python3.9, as it relies on distutils, however I don't think the documentation mentions this anywhere. I had to alias my python3 command.
Running pipelinec --help works as expected and exits without error.
Perhaps I'm doing something wrong/my environment is wrong.

Versions:

  • PipelineC commit 28786db (current head)
  • python3.9 --version: Python 3.9.20
  • MacOS 15.1.1 (Apple M4)
  • cpp --version: Apple clang version 16.0.0 (clang-1600.0.26.4) (Target: arm64-apple-darwin24.1.0)

Additional interesting outputs from examples:

% ./src/pipelinec ./examples/adder_tree.c

██████╗ ██╗██████╗ ███████╗██╗     ██╗███╗   ██╗███████╗ ██████╗
██╔══██╗██║██╔══██╗██╔════╝██║     ██║████╗  ██║██╔════╝██╔════╝
██████╔╝██║██████╔╝█████╗  ██║     ██║██╔██╗ ██║█████╗  ██║
██╔═══╝ ██║██╔═══╝ ██╔══╝  ██║     ██║██║╚██╗██║██╔══╝  ██║
██║     ██║██║     ███████╗███████╗██║██║ ╚████║███████╗╚██████╗
╚═╝     ╚═╝╚═╝     ╚══════╝╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝ ╚═════╝

Output directory: /.../PipelineC/pipelinec_output_adder_tree.c_56776
================== Parsing C Code to Logical Hierarchy ================================
Parsing: /.../PipelineC/examples/adder_tree.c
Preprocessing file...
Parsing C syntax...
pycparser says you messed up: /.../PipelineC/examples/adder_tree.c:2:1: before: /
% ./src/pipelinec ./examples/fir.c

██████╗ ██╗██████╗ ███████╗██╗     ██╗███╗   ██╗███████╗ ██████╗
██╔══██╗██║██╔══██╗██╔════╝██║     ██║████╗  ██║██╔════╝██╔════╝
██████╔╝██║██████╔╝█████╗  ██║     ██║██╔██╗ ██║█████╗  ██║
██╔═══╝ ██║██╔═══╝ ██╔══╝  ██║     ██║██║╚██╗██║██╔══╝  ██║
██║     ██║██║     ███████╗███████╗██║██║ ╚████║███████╗╚██████╗
╚═╝     ╚═╝╚═╝     ╚══════╝╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝ ╚═════╝

Output directory: /.../PipelineC/pipelinec_output_fir.c_55965
================== Parsing C Code to Logical Hierarchy ================================
Parsing: /.../PipelineC/examples/fir.c
Traceback (most recent call last):
  File "/.../PipelineC/./src/pipelinec", line 220, in <module>
    parser_state = C_TO_LOGIC.PARSE_FILE(c_file)
  File "/.../PipelineC/src/C_TO_LOGIC.py", line 9986, in PARSE_FILE
    all_code_files = get_included_files(c_filename)
  File "/.../PipelineC/src/C_TO_LOGIC.py", line 214, in get_included_files
    include_str = GET_SHELL_CMD_OUTPUT(cmd)
  File "/.../PipelineC/src/C_TO_LOGIC.py", line 254, in GET_SHELL_CMD_OUTPUT
    raise Exception(e_text)
Exception: Command failed:
cpp -MM -MG -I/.../PipelineC/pipelinec_output_fir.c_55965/var_clock_cross.h -I/.../PipelineC/pipelinec_output_fir.c_55965/type_array_N_t.h -I/.../PipelineC/pipelinec_output_fir.c_55965/type_bytes_t.h -I/.../PipelineC/pipelinec_output_fir.c_55965/func_FSM.h -I/.../PipelineC/pipelinec_output_fir.c_55965/func_SINGLE_INST.h -I/.../PipelineC/ -I/.../PipelineC/pipelinec/include/ -I/.../PipelineC/include/ -D__PIPELINEC__ /.../PipelineC/examples/fir.c
In file included from /.../PipelineC/examples/fir.c:49:
In file included from /.../PipelineC/include/dsp/fir_decim.h:28:
/.../PipelineC/include/dsp/fir.h:34:1: error: _Pragma takes a parenthesized string literal
   34 | PRAGMA_MESSAGE(FUNC_WIRES fir_samples_window) // Not worried about delay of this func
      | ^
/.../PipelineC/include/compiler.h:66:27: note: expanded from macro 'PRAGMA_MESSAGE'
   66 | #define PRAGMA_MESSAGE(x) PRAGMA_MESSAGE_(x)
      |                           ^
/.../PipelineC/include/compiler.h:65:28: note: expanded from macro 'PRAGMA_MESSAGE_'
   65 | #define PRAGMA_MESSAGE_(x) _Pragma(#x)
      |                            ^
In file included from /.../PipelineC/examples/fir.c:49:
/.../PipelineC/include/dsp/fir_decim.h:32:1: error: _Pragma takes a parenthesized string literal
   32 | PRAGMA_MESSAGE(FUNC_WIRES fir_decim_counter) // Not worried about delay of this func
      | ^
/.../PipelineC/include/compiler.h:66:27: note: expanded from macro 'PRAGMA_MESSAGE'
   66 | #define PRAGMA_MESSAGE(x) PRAGMA_MESSAGE_(x)
      |                           ^
/.../PipelineC/include/compiler.h:65:28: note: expanded from macro 'PRAGMA_MESSAGE_'
   65 | #define PRAGMA_MESSAGE_(x) _Pragma(#x)
      |                            ^
2 errors generated.

fir.o: /.../PipelineC/examples/fir.c \
  /.../PipelineC/include/intN_t.h \
  /.../PipelineC/include/uintN_t.h \
  /.../PipelineC/include/stream/stream.h \
  /.../PipelineC/include/compiler.h \
  /.../PipelineC/include/bool.h \
  /.../PipelineC/include/dsp/fir_decim.h \
  /.../PipelineC/include/dsp/fir_decim_names.h \
  /.../PipelineC/include/dsp/fir_names.h \
  /.../PipelineC/include/dsp/fir.h \
  /.../PipelineC/include/binary_tree.h
% ./src/pipelinec ./examples/handshake_io.c

██████╗ ██╗██████╗ ███████╗██╗     ██╗███╗   ██╗███████╗ ██████╗
██╔══██╗██║██╔══██╗██╔════╝██║     ██║████╗  ██║██╔════╝██╔════╝
██████╔╝██║██████╔╝█████╗  ██║     ██║██╔██╗ ██║█████╗  ██║
██╔═══╝ ██║██╔═══╝ ██╔══╝  ██║     ██║██║╚██╗██║██╔══╝  ██║
██║     ██║██║     ███████╗███████╗██║██║ ╚████║███████╗╚██████╗
╚═╝     ╚═╝╚═╝     ╚══════╝╚══════╝╚═╝╚═╝  ╚═══╝╚══════╝ ╚═════╝

Output directory: /.../PipelineC/pipelinec_output_handshake_io.c_57595
================== Parsing C Code to Logical Hierarchy ================================
Parsing: /.../PipelineC/examples/handshake_io.c
Traceback (most recent call last):
  File "/.../PipelineC/./src/pipelinec", line 220, in <module>
    parser_state = C_TO_LOGIC.PARSE_FILE(c_file)
  File "/.../PipelineC/src/C_TO_LOGIC.py", line 9986, in PARSE_FILE
    all_code_files = get_included_files(c_filename)
  File "/.../PipelineC/src/C_TO_LOGIC.py", line 214, in get_included_files
    include_str = GET_SHELL_CMD_OUTPUT(cmd)
  File "/.../PipelineC/src/C_TO_LOGIC.py", line 254, in GET_SHELL_CMD_OUTPUT
    raise Exception(e_text)
Exception: Command failed:
cpp -MM -MG -I/.../PipelineC/pipelinec_output_handshake_io.c_57595/var_clock_cross.h -I/.../PipelineC/pipelinec_output_handshake_io.c_57595/type_array_N_t.h -I/.../PipelineC/pipelinec_output_handshake_io.c_57595/type_bytes_t.h -I/.../PipelineC/pipelinec_output_handshake_io.c_57595/func_FSM.h -I/.../PipelineC/pipelinec_output_handshake_io.c_57595/func_SINGLE_INST.h -I/.../PipelineC/ -I/.../PipelineC/pipelinec/include/ -I/.../PipelineC/include/ -D__PIPELINEC__ /.../PipelineC/examples/handshake_io.c
/.../PipelineC/examples/handshake_io.c:93:1: error: _Pragma takes a parenthesized string literal
   93 | DECL_INPUT(uint32_t, s_axis_tdata)
      | ^
/.../PipelineC/include/compiler.h:97:14: note: expanded from macro 'DECL_INPUT'
   97 | type_t name; \
      |              ^
/.../PipelineC/include/compiler.h:66:27: note: expanded from macro '\
PRAGMA_MESSAGE'
   66 | #define PRAGMA_MESSAGE(x) PRAGMA_MESSAGE_(x)
      |                           ^
/.../PipelineC/include/compiler.h:65:28: note: expanded from macro 'PRAGMA_MESSAGE_'
   65 | #define PRAGMA_MESSAGE_(x) _Pragma(#x)
      |                            ^
/.../PipelineC/examples/handshake_io.c:93:1: error: _Pragma takes a parenthesized string literal
/.../PipelineC/include/compiler.h:98:27: note: expanded from macro 'DECL_INPUT'
   98 | PRAGMA_MESSAGE(MAIN name) \
      |                           ^
/.../PipelineC/include/compiler.h:66:27: note: expanded from macro '\
PRAGMA_MESSAGE'
   66 | #define PRAGMA_MESSAGE(x) PRAGMA_MESSAGE_(x)
      |                           ^
/.../PipelineC/include/compiler.h:65:28: note: expanded from macro 'PRAGMA_MESSAGE_'
   65 | #define PRAGMA_MESSAGE_(x) _Pragma(#x)
      |                            ^
/.../PipelineC/examples/handshake_io.c:94:1: error: _Pragma takes a parenthesized string literal
   94 | DECL_INPUT(uint4_t, s_axis_tkeep)
      | ^
/.../PipelineC/include/compiler.h:97:14: note: expanded from macro 'DECL_INPUT'
   97 | type_t name; \
      |              ^
/.../PipelineC/include/compiler.h:66:27: note: expanded from macro '\
PRAGMA_MESSAGE'
   66 | #define PRAGMA_MESSAGE(x) PRAGMA_MESSAGE_(x)
      |                           ^

[removed additional output for brevity, more of the same pragma errors as above]

fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.

handshake_io.o: \
  /.../PipelineC/examples/handshake_io.c \
  /.../PipelineC/include/arrays.h \
  /.../PipelineC/include/handshake/handshake.h \
  /.../PipelineC/include/compiler.h \
  /.../PipelineC/include/bool.h \
  /.../PipelineC/include/uintN_t.h \
  /.../PipelineC/include/stream/stream.h
@JulianKemmerer
Copy link
Owner

JulianKemmerer commented Dec 1, 2024 via email

@JulianKemmerer
Copy link
Owner

Ah OK - I missed the part about this being on Mac.

I am not able to recreate this on my Linux system.

PipelineC has only ever been tested on Linux, so I am just starting to speculate about what could be going on for you. (and any python3 version should work fine out of the box, why not specified specific version for non-developers).

/.../PipelineC/examples/blink.c:1:23: warning: extra tokens at end of #include directive [-Wextra-tokens]
    1 | #include "uintN_t.h"  // uintN_t types for any N
      |                       ^
      |                       //
1 warning generated.
Parsing C syntax...
pycparser says you messed up: /.../PipelineC/include/uintN_t.h:2:1: before: /

Seems like something is wrong dealing with include statements during preprocessing. Is cpp on Mac still the C preprocessor or something else?

At one point there was an issue of some cpp versions not having the same cmd line args: #166

I am going to make a general issue for 'pipelinec doesnt work on mac' and tag you in it, continue investigating there.

In the short term using PipelineC on a Linux machine, virtual even, is the recommended fix.

@JulianKemmerer
Copy link
Owner

If you don't want to jump over to a Linux system to continue, lets discuss further if we can make things work over on Mac #286 👍

@playduck
Copy link
Author

playduck commented Dec 1, 2024

Right, I just tested it again in a Ubuntu 20.04 VM (via UTM, virtualized so still arm-based) and the blink example works as expected.

This is likely an issue with Apple's clang not being 1:1 compatible with the cpp compiler.
Definitely a viable workaround, still a bit weird. Would be interesting to know why clang seems to have problems with its preprocessor.

@playduck playduck closed this as completed Dec 1, 2024
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

No branches or pull requests

2 participants