Skip to content

Windows re_syntax_options #325

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

Closed
wants to merge 1 commit into from
Closed

Conversation

jmkristian
Copy link
Contributor

When building regex for Windows, don't repeatedly define the global variable re_syntax_options.

@jmkristian
Copy link
Contributor Author

When I tried building without this change, the output from make -j4 contained numerous lines like:

/usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/direwolf.dir/ax25_link.c.o:ax25_link.c:(.bss+0x0): multiple definition of `re_syntax_options'; CMakeFiles/direwolf.dir/direwolf.c.o:direwolf.c:(.bss+0x0): first defined here
/usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/direwolf.dir/ax25_pad.c.o:ax25_pad.c:(.bss+0x4): multiple definition of `re_syntax_options'; CMakeFiles/direwolf.dir/direwolf.c.o:direwolf.c:(.bss+0x0): first defined here
/usr/lib/gcc/x86_64-w64-mingw32/10/../../../../x86_64-w64-mingw32/bin/ld: CMakeFiles/atest.dir/decode_aprs.c.o:decode_aprs.c:(.bss+0x0): multiple definition of `re_syntax_options'; CMakeFiles/atest.dir/ax25_pad.c.o:ax25_pad.c:(.bss+0x4): first defined here

I used Windows 8.1 Pro. I didn't install the Cygwin packages libboost_regex or perl-Regexp-Common. The output from cmake -DUNITTEST=1 .. contained:

-- The C compiler identification is GNU 10.2.0
-- The CXX compiler identification is GNU 10.2.0
-- Dire Wolf Version: 1.7.0-7fa91dd
-- Build type set to: Release
CMake system: CYGWIN
-- Target architecture: x86_64
-- Could NOT find HAMLIB (missing: HAMLIB_LIBRARY HAMLIB_INCLUDE_DIR)

@stltracker
Copy link

An alternative fix to this problem is to add -fcommon to CMAKE_C_FLAGS:

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -203,9 +203,9 @@ if (C_CLANG OR C_GCC)
#
###set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wvla -ffast-math -ftree-vectorize -D_XOPEN_SOURCE=600 -D_DEFAULT_SOURCE ${EXTRA_FLAGS}")
if(FREEBSD)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wvla -ffast-math -ftree-vectorize -D_DEFAULT_SOURCE ${EXTRA_FLAGS}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wvla -ffast-math -ftree-vectorize -fcommon -D_DEFAULT_SOURCE ${EXTRA_FLAGS}")
else()
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wvla -ffast-math -ftree-vectorize -D_GNU_SOURCE ${EXTRA_FLAGS}")
+ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wvla -ffast-math -ftree-vectorize -fcommon -D_GNU_SOURCE ${EXTRA_FLAGS}")
endif()
#
#

@wb2osz
Copy link
Owner

wb2osz commented Apr 10, 2021

This is due to a change in gcc behavior:

https://gcc.gnu.org/gcc-10/changes.html

GCC now defaults to -fno-common. As a result, global variable accesses are more efficient on various targets. In C, global variables with multiple tentative definitions now result in linker errors. With -fcommon such definitions are silently merged during linking.

@wb2osz
Copy link
Owner

wb2osz commented Apr 11, 2021

This has been added to the 'dev' development branch.
Thanks for identifying and fixing the problem.

@wb2osz wb2osz closed this Apr 11, 2021
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.

3 participants