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

Compiling from source mosquitto v1.5 on FreeBSD bug #863

Closed
denigmus opened this issue Jun 20, 2018 · 18 comments
Closed

Compiling from source mosquitto v1.5 on FreeBSD bug #863

denigmus opened this issue Jun 20, 2018 · 18 comments
Labels
Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Milestone

Comments

@denigmus
Copy link

denigmus commented Jun 20, 2018

git clone --branch v1.5 https://github.com/eclipse/mosquitto
cd mosquitto
gmake

cc sub_client.o sub_client_output.o client_shared.o -o mosquitto_sub  -L../lib ../lib/libmosquitto.so.1
gmake[1]: Leaving directory '/root/MOSQUITTO-UPDATE/mosquitto/client'
gmake[1]: Entering directory '/root/MOSQUITTO-UPDATE/mosquitto/src'
cc -Wall -ggdb -O2  -I. -I.. -I../lib  -DVERSION="\"1.5\"" -DWITH_BROKER -DWITH_TLS -DWITH_TLS_PSK -DWITH_BRIDGE -DWITH_PERSISTENCE -DWITH_MEMORY_TRACKING -DWITH_SYS_TREE -DWITH_EC -c mosquitto.c -o mosquitto.o
mosquitto.c:104:7: warning: implicit declaration of function 'initgroups' is invalid in C99 [-Wimplicit-function-declaration]
                        if(initgroups(config->user, pwd->pw_gid) == -1){
                           ^
mosquitto.c:231:2: warning: implicit declaration of function 'gettimeofday' is invalid in C99 [-Wimplicit-function-declaration]
        gettimeofday(&tv, NULL);
        ^
2 warnings generated.
cc -Wall -ggdb -O2  -I. -I.. -I../lib  -DVERSION="\"1.5\"" -DWITH_BROKER -DWITH_TLS -DWITH_TLS_PSK -DWITH_BRIDGE -DWITH_PERSISTENCE -DWITH_MEMORY_TRACKING -DWITH_SYS_TREE -DWITH_EC -c bridge.c -o bridge.o
cc -Wall -ggdb -O2  -I. -I.. -I../lib  -DVERSION="\"1.5\"" -DWITH_BROKER -DWITH_TLS -DWITH_TLS_PSK -DWITH_BRIDGE -DWITH_PERSISTENCE -DWITH_MEMORY_TRACKING -DWITH_SYS_TREE -DWITH_EC -c conf.c -o conf.o
conf.c:117:24: error: use of undeclared identifier 'PF_UNSPEC'
        gai_hints.ai_family = PF_UNSPEC;
                              ^
1 error generated.
gmake[1]: *** [Makefile:68: conf.o] Error 1
gmake[1]: Leaving directory '/root/MOSQUITTO-UPDATE/mosquitto/src'
gmake: *** [Makefile:26: mosquitto] Error 2

FreeBSD 11.1-RELEASE-p8

gmake -v
GNU Make 4.2.1
Built for amd64-portbld-freebsd11.1

cc -v
FreeBSD clang version 4.0.0 (tags/RELEASE_400/final 297347) (based on LLVM 4.0.0)
Target: x86_64-unknown-freebsd11.1
Thread model: posix
InstalledDir: /usr/bin

@ptjm
Copy link

ptjm commented Jun 23, 2018

This is caused by defining _POSIX_C_SOURCE 200809 (in config.h). You could fix it by wrapping an #ifndef FreeBSD/#endif around that definition.

@karlp
Copy link
Contributor

karlp commented Jun 24, 2018

@ptjm say that again? is some bsd compiler saying it's posix 200809 compatible, but it's not? that's a bsd bug, not somethign that should be fixed here.

@denigmus
Copy link
Author

@ptjm

#else
#  define _DEFAULT_SOURCE 1
#   ifndef FreeBSD
#     define _POSIX_C_SOURCE 200809L
#   endif
#endif

Correct?
Doesn't help.

@ptjm
Copy link

ptjm commented Jun 26, 2018

@denigmus - sorry the markdown parser turned my text into formatting. There should be two underscores on either side of FreeBSD.

#else
#  define _DEFAULT_SOURCE 1
#   ifndef __FreeBSD__
#     define _POSIX_C_SOURCE 200809L
#   endif
#endif

@karlp - if you define _POSIX_C_SOURCE, you're supposed to write code which conforms to that version of the SUS. PF_UNSPEC is a non-standard BSDism and a conforming system will not define it if _POSIX_C_SOURCE is defined. That means using AF_UNSPEC, since that's what the standard defines, and while it's annoying that some systems don't define manifest constants which aren't in the standard while others do, what the standard says is that this is what is supposed to happen. Anyway, if you want to argue that mosquitto shouldn't compile on systems which don't define PF_UNSPEC in these circumstances, why not start with darwin, where _POSIX_C_SOURCE is deliberately not defined for exactly this reason in the #if part of the block cited above?

@karlp
Copy link
Contributor

karlp commented Jun 26, 2018

@ptjm if mosquitto is misusing posix source guards, then mosquitto should be fixed. But fixed to use posix source properly. Just saying that it's posix source for one OS, and non-posix source for another isn't fixing anything, it's just making a tangled mess. From what you're saying, clearly, mosquitto should be using AF_UNSPEC, rather than hacking on these include guards.

@toast-uz
Copy link
Contributor

What is the result?

@toast-uz toast-uz added the Status: Blocked Another issue needs to be resolved first label Jul 31, 2018
@denigmus
Copy link
Author

Compiled

@toast-uz
Copy link
Contributor

Thanks. Shall I close this?

@toast-uz toast-uz added not a bug and removed Status: Blocked Another issue needs to be resolved first labels Jul 31, 2018
@denigmus
Copy link
Author

Yep if no one wants to add this fix to the code ;)

@karlp
Copy link
Contributor

karlp commented Aug 1, 2018

@toast-uz NO! stop this! what on earth makes you think this is resolved?!

@toast-uz
Copy link
Contributor

toast-uz commented Aug 1, 2018

Did I misunderstand @denigmus comment?

@toast-uz
Copy link
Contributor

toast-uz commented Aug 1, 2018

Sorry, I understood @karlp insisted mosquitto should not be fixed. and rejected @denigmus and @ptjm 's submitting fix, and @denigmus agreed. Misunderstood?

@toast-uz toast-uz reopened this Aug 1, 2018
@toast-uz toast-uz added Status: Blocked Another issue needs to be resolved first and removed not a bug labels Aug 1, 2018
@denigmus
Copy link
Author

denigmus commented Aug 1, 2018

I'm not a person to decide what to do with it. I don't even know C. I just said that @ptjm's fix has helped me to compile on FreeBSD.

@toast-uz
Copy link
Contributor

toast-uz commented Aug 1, 2018

@karlp , @denigmus , I have no expertise on this topic. Just I'd like to melt and proceed this frozen issue. So please show your intent clearly and agree with each other.

@ptjm
Copy link

ptjm commented Aug 1, 2018

If I ever get around to dealing with the eclipse IP, I'll submit a pull request to get at the root issue -- replacing PF_* with AF_* to match POSIX.

@ralight ralight added Type: Bug Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. and removed Status: Blocked Another issue needs to be resolved first labels Aug 1, 2018
ralight added a commit that referenced this issue Aug 1, 2018
Closes #863.

Thanks to denigmus and Patrick TJ McPhee.

Signed-off-by: Roger A. Light <[email protected]>
@ralight
Copy link
Contributor

ralight commented Aug 1, 2018

I've made the change of PF_* to AF_*, thanks for explaining where the actual issue was. If you are able to try compiling the fixes branch again, hopefully it should work fine for you and we can then close the issue.

@ralight ralight added this to the 1.5.1 milestone Aug 1, 2018
@ptjm
Copy link

ptjm commented Aug 6, 2018

Hi. I was able to compile the fixes branch on freebsd 11.2 using both clang and gcc

@ralight
Copy link
Contributor

ralight commented Aug 14, 2018

Thanks for checking, I'm closing the issue.

@ralight ralight closed this as completed Aug 14, 2018
ralight added a commit that referenced this issue Nov 8, 2018
Closes #863.

Thanks to denigmus and Patrick TJ McPhee.

Signed-off-by: Roger A. Light <[email protected]>
@lock lock bot locked as resolved and limited conversation to collaborators Aug 7, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Component: mosquitto-broker Status: Completed Nothing further to be done with this issue, it can be closed by the requestor or committer. Type: Bug
Projects
None yet
Development

No branches or pull requests

5 participants