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

Update rebar.config to allow compilation on Windows #4

Merged
merged 1 commit into from
Nov 20, 2023

Conversation

big-r81
Copy link
Contributor

@big-r81 big-r81 commented Nov 8, 2023

Add compiler flags for Windows (MSVC).

Fixes #3.

rnewson added a commit to apache/couchdb that referenced this pull request Nov 9, 2023
rnewson added a commit to apache/couchdb that referenced this pull request Nov 10, 2023
rnewson added a commit to apache/couchdb that referenced this pull request Nov 10, 2023
rnewson added a commit to apache/couchdb that referenced this pull request Nov 10, 2023
rnewson added a commit to apache/couchdb that referenced this pull request Nov 10, 2023
rnewson added a commit to apache/couchdb that referenced this pull request Nov 10, 2023
@NelsonVides
Copy link
Collaborator

Hi @big-r81! Thanks a lot for this PR. Unfortunately, it fails to build in linux, I'm pasting you below the rebar3.crashdump I generated locally (with some lines removed for privacy), hopefully it can help you debug the issue. Let me know if you need any assistance :)

Error: function_clause
[{pc_port_env,'-merge_each_var/1-fun-0-',
              [{"(linux|solaris|darwin|freebsd)","CFLAGS",
                "$CFLAGS -std=c99 -O3 -g -Wall -Wextra -fPIC"},
               [{"AR","ar"},
                {"AS","as"},
                {"ASDF_DIR","/home/videsnelson/.asdf"},
                {"BINDIR",
                 "/home/videsnelson/.asdf/installs/erlang/26.1.2/erts-14.1.1/bin"},
                {"CC","cc"},
                {"CPP","cpp"},
                {"CXX","c++"},
                {"DRV_CC_TEMPLATE",
                 "$CC -c $CFLAGS $DRV_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
                {"DRV_CFLAGS","-g -Wall -fPIC -MMD $ERL_CFLAGS"},
                {"DRV_CXX_TEMPLATE",
                 "$CXX -c $CXXFLAGS $DRV_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
                {"DRV_LDFLAGS","-shared $ERL_LDFLAGS"},
                {"DRV_LINK_CXX_TEMPLATE",
                 "$CXX $PORT_IN_FILES $LDFLAGS $LDLIBS $DRV_LDFLAGS -o $PORT_OUT_FILE"},
                {"DRV_LINK_TEMPLATE",
                 "$CC $PORT_IN_FILES $LDFLAGS $LDLIBS $DRV_LDFLAGS -o $PORT_OUT_FILE"},
                {"EDITOR","nvim"},
                {"EMU","beam"},
                {"ERLANG_ARCH","64"},
                {"ERLANG_TARGET","26.1.2-x86_64-pc-linux-gnu-64"},
                {"ERL_AFLAGS",
                 "+pc unicode -kernel shell_history enabled -enable-feature all"},
                {"ERL_CFLAGS",
                 " -I\"/home/videsnelson/.asdf/installs/erlang/26.1.2/lib/erl_interface-5.4/include\" -I\"/home/videsnelson/.asdf/installs/erlang/26.1.2/erts-14.1.1/include\" "},
                {"ERL_EI_LIBDIR",
                 "\"/home/videsnelson/.asdf/installs/erlang/26.1.2/lib/erl_interface-5.4/lib\""},
                {"ERL_LDFLAGS"," -L$ERL_EI_LIBDIR -lei"},
                {"ESCRIPT_NAME",
                 "/home/videsnelson/.asdf/installs/rebar/3.22.1/bin/rebar3"},
                {"EXE_CC_TEMPLATE",
                 "$CC -c $CFLAGS $EXE_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
                {"EXE_CFLAGS","-g -Wall -fPIC -MMD $ERL_CFLAGS"},
                {"EXE_CXX_TEMPLATE",
                 "$CXX -c $CXXFLAGS $EXE_CFLAGS $PORT_IN_FILES -o $PORT_OUT_FILE"},
                {"EXE_LDFLAGS","$ERL_LDFLAGS"},
                {"EXE_LINK_CXX_TEMPLATE",
                 "$CXX $PORT_IN_FILES $LDFLAGS $EXE_LDFLAGS -o $PORT_OUT_FILE"},
                {"EXE_LINK_TEMPLATE",
                 "$CC $PORT_IN_FILES $LDFLAGS $EXE_LDFLAGS -o $PORT_OUT_FILE"},
                {"GPG_TTY","/dev/pts/38"},
                {"HOME","/home/videsnelson"},
                {"LC_ALL","en_GB.UTF-8"},
                {"LC_CTYPE","UTF-8"},
                {"LC_TERMINAL","iTerm2"},
                {"LC_TERMINAL_VERSION","3.4.22"},
                {"LD","ld"},
                {"LESS","-R"},
                {"LOGNAME","videsnelson"},
                {"LS_COLORS",
                 "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.webp=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:"},
                {"OBJCOPY","objcopy"},
                {"OBJDUMP","objdump"},
                {"PAGER","less"},
                {"PROGNAME","erl"},
                {"PWD","/home/videsnelson/repos/fast_pbkdf2"},
                {"RANLIB","ranlib"},
                {"ROOTDIR","/home/videsnelson/.asdf/installs/erlang/26.1.2"},
                {"SHELL","/usr/bin/zsh"},
                {"SHLVL","2"},
                {"STRIP","strip"},
                {"TERM","screen-256color"},
                {"TERM_PROGRAM","tmux"},
                {"TERM_PROGRAM_VERSION","3.3a"},
                {"TMUX","/tmp/tmux-1000/default,285894,1"},
                {"TMUX_PANE","%55"},
                {"TMUX_PLUGIN_MANAGER_PATH",
                 "/home/videsnelson/.tmux/plugins/"},
                {"USER","videsnelson"},
                {"XDG_RUNTIME_DIR","/run/user/1000"},
                {"ZSH","/home/videsnelson/.oh-my-zsh"},
                {"ZSH_TMUX_CONFIG","/home/videsnelson/.tmux.conf"},
                {"ZSH_TMUX_TERM","screen-256color"},
                {"_P9K_TTY","/dev/pts/38"},
                {"_ZSH_TMUX_FIXED_CONFIG",
                 "/home/videsnelson/.oh-my-zsh/plugins/tmux/tmux.extra.conf"}]],
              [{file,"/home/videsnelson/repos/fast_pbkdf2/_build/default/plugins/pc/src/pc_port_env.erl"},
               {line,61}]},
 {pc_port_env,'-merge_each_var/1-lists^foldl/2-1-',3,
              [{file,"/home/videsnelson/repos/fast_pbkdf2/_build/default/plugins/pc/src/pc_port_env.erl"},
               {line,61}]},
 {pc_port_env,construct,2,
              [{file,"/home/videsnelson/repos/fast_pbkdf2/_build/default/plugins/pc/src/pc_port_env.erl"},
               {line,49}]},
 {pc_port_specs,port_opt,2,
                [{file,"/home/videsnelson/repos/fast_pbkdf2/_build/default/plugins/pc/src/pc_port_specs.erl"},
                 {line,244}]},
 {pc_port_specs,'-get_port_spec/3-lc$^2/1-2-',2,
                [{file,"/home/videsnelson/repos/fast_pbkdf2/_build/default/plugins/pc/src/pc_port_specs.erl"},
                 {line,197}]},
 {pc_port_specs,get_port_spec,3,
                [{file,"/home/videsnelson/repos/fast_pbkdf2/_build/default/plugins/pc/src/pc_port_specs.erl"},
                 {line,197}]},
 {pc_port_specs,'-construct/1-lc$^1/1-1-',2,
                [{file,"/home/videsnelson/repos/fast_pbkdf2/_build/default/plugins/pc/src/pc_port_specs.erl"},
                 {line,68}]},
 {pc_port_specs,construct,1,
                [{file,"/home/videsnelson/repos/fast_pbkdf2/_build/default/plugins/pc/src/pc_port_specs.erl"},
                 {line,68}]}]

@big-r81
Copy link
Contributor Author

big-r81 commented Nov 13, 2023

@NelsonVides Hi, unfortunately I can't reproduce this locally on an Ubuntu 22.04 VM. I tested it with Erlang v24.2.1. Maybe it's something with the GI CI?

@NelsonVides
Copy link
Collaborator

@NelsonVides Hi, unfortunately I can't reproduce this locally on an Ubuntu 22.04 VM. I tested it with Erlang v24.2.1. Maybe it's something with the GI CI?

I could reproduce at home on an ubuntu 22.04 native server, with Erlang 26.1, 25.3, and 24.3, so it seems pretty reproducible to me unfortunately, though that might make it easier to fix. All three versions generate the same crashdump as pasted above 🥲

@NelsonVides
Copy link
Collaborator

Also tried on my intel-based mac and the same error happens. I don't have a silicon mac nor a windows to try it out though. Do you think the crashdump could help you with a fix? Seems like the port_compiler didn't like something.

@big-r81
Copy link
Contributor Author

big-r81 commented Nov 14, 2023

@NelsonVides Hi, I know why it was working on my side. We use rebar2 for compiling and not rebar3. With rebar2 all is working, with rebar3, I get your errors too. Do you have any idea how to port this to rebar3?

@NelsonVides
Copy link
Collaborator

Oooooh, rebar2, I see! Well, that's quite an old one, I'm lost there 😅
I'm having a look at jiffy's usage of the port compiler, it also has flags for Windows and ARM macs and it compiles with rebar3, perhaps good hints can be taken from there: https://github.com/davisp/jiffy/blob/master/rebar.config 🤔

@big-r81
Copy link
Contributor Author

big-r81 commented Nov 16, 2023

@NelsonVides Hey, I updated the PR. It should work under Windows/*nix and Rebar 2/3.

Copy link
Collaborator

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

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

Beautiful! Only one thing is code coverage for the C code, see
https://app.codecov.io/github/esl/fast_pbkdf2/tree/patch-1
in comparison to master in
https://app.codecov.io/github/esl/fast_pbkdf2
the c_src directory is not listed.

That's why I had duplicated the port compiler directories with a global config and an overriding one in the test profile, the test one had an extra CFLAGS and LDFLAGS one, --coverage :)

@big-r81 big-r81 force-pushed the patch-1 branch 15 times, most recently from 0b616fc to 607a206 Compare November 17, 2023 17:13
@big-r81 big-r81 force-pushed the patch-1 branch 2 times, most recently from 5cf0501 to d447560 Compare November 17, 2023 17:20
Add compiler flags for Windows (MSVC).
@big-r81
Copy link
Contributor Author

big-r81 commented Nov 17, 2023

@NelsonVides Hi, can you look if the coverage is increased? I updated thr PR again...

Copy link
Collaborator

@NelsonVides NelsonVides left a comment

Choose a reason for hiding this comment

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

Beautiful! Now it all works! 💪🏽

Will cleanup github actions scripts and prepare a new release in hex. Thanks for the PR, very nice 😄

@NelsonVides NelsonVides merged commit a8c90f2 into esl:main Nov 20, 2023
4 checks passed
@NelsonVides NelsonVides mentioned this pull request Nov 20, 2023
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.

Compilation error in Windows 10 - "invalid numeric argument '/Wextra'"
2 participants