-
Notifications
You must be signed in to change notification settings - Fork 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
Replace all #define _*_SOURCE
with centralised config
#855
base: master
Are you sure you want to change the base?
Conversation
Slightly cleaner alternative to gphoto#843, gphoto#615, gphoto#552 and others that ensures we always have those extension functions at autoconf level instead of having individual (and inconsistent) `#define`s in source files.
I have two remarks about this:
This PR requires Do we actually want consistent #defines for all compilation units? I do not remember whether we require inconsistent #defines in different compilation units because we might e.g. use one kind of strerror_r function definition in one compilation unit and the other function definition in another compilation unit. Have you checked that? It might be non-trivial to check that as just enabling all compiler warnings produces so many of them with the current codebase that any changes to the set of warnings produced are difficult to see. Conclusion If/When those two remarks can be addressed/resolved, I like this. |
I'm happy to replace with manual defines. I suppose
That would be pretty surprising, but sure, worth checking. [...] I just tried couple of methods I could think of - sha256sum of all object files, collecting preprocessed sources, few others, but I'm not getting deterministic enough results for them to be useful to compare :( |
Ahh right I suppose the object files I got are not deterministic due to LINE used in various error loggers (which changed now). I'll play a bit more. |
Ok I spent unreasonable amount of time on this given that it's not really even important, but I think I got there 😅 --- sha256-before.log 2022-10-31 03:25:00.192112000 +0000
+++ sha256-after.log 2022-10-31 03:28:58.502112000 +0000
@@ -179,7 +179,7 @@
6fc7f33fd2aab861743093ae3a582db7b9de684adb9515b9b6f65406387e6d36 ./camlibs/topfield/.libs/la-tf_bytes.o
b5d6382c2d29fb112590ef4472d18f703b194454dd718792a812de51f1d1c5e3 ./camlibs/topfield/.libs/la-usb_io.o
1816f93b7fce6e443c7c86e439c686bd6616cff5eddca6ea7d9461190c92b4f9 ./camlibs/toshiba/pdrm11/.libs/la-library.o
-08764a8af34118a885821ed43efa80a3b2d46f059059bf56b0ced2c7d836822c ./camlibs/toshiba/pdrm11/.libs/la-pdrm11.o
+5a15f3a5c6ee908cae1f350db7b4b8228e7b60c7bd022b666f38a311184161ac ./camlibs/toshiba/pdrm11/.libs/la-pdrm11.o
23e22a439777082acc6c5eaa216e7241a1d58ab21e62458cf7a23bd5bdf87957 ./camlibs/tp6801/.libs/la-library.o
d727f1039d0b8e0b7462caaa1b7c70740e9594a091939e0b593622a0e7f0daae ./camlibs/tp6801/.libs/la-tp6801.o
bc1de4ffd5d150ab1a8c49ea863ad6ec2cc77e115e2aff4528f46a9bc1656d96 ./examples/autodetect.o
@@ -214,7 +214,7 @@
3ff37d1ad5587dcde7c1bb67e96ef9dffcb887e3cca03ac1d2d6030ee3018a5d ./libgphoto2/.libs/libgphoto2_la-gphoto2-widget.o
6e7e8346eb4aa6c76c368a9f8a28e04aa35ba082da27280e82f6ea4fcd086170 ./libgphoto2/.libs/libgphoto2_la-jpeg.o
5c37d3744667213ede3078b7e0149b5d465c1e07f0c675b40a5cc1cb92678dd5 ./libgphoto2_port/disk/.libs/la-disk.o
-3d57472d6edfbc546ee49197e748352cca424aae59fb1e882e98678b7b445e2b ./libgphoto2_port/libgphoto2_port/.libs/libgphoto2_port_la-gphoto2-port-info-list.o
+df1e0655abf4936f7f232466e05b6ce8d1fec171cc58fb9c23376cf51f584dc5 ./libgphoto2_port/libgphoto2_port/.libs/libgphoto2_port_la-gphoto2-port-info-list.o
a80acf8228fcbd36a916a0313aaf6e031c3b2d8119ac05c0d97c88a9d734bc72 ./libgphoto2_port/libgphoto2_port/.libs/libgphoto2_port_la-gphoto2-port-log.o
2f14039c0af4641622602596c906cdcd8b71ee21f424d41d834d8fe47dc80d2e ./libgphoto2_port/libgphoto2_port/.libs/libgphoto2_port_la-gphoto2-port-portability.o
aa9447f5933d719a250f659273aa531dacc9606986137a17b585050738bd03e5 ./libgphoto2_port/libgphoto2_port/.libs/libgphoto2_port_la-gphoto2-port-result.o I'm not yet sure why it's always the Toshiba's camlibs/toshiba/pdrm11 and gphoto2-port-info-list that have different hashes. Toshiba is especially weird given that it is not even among the changed files, but the gphoto2-port-info-list.c might warrant further look as it actually used _GNU_SOURCE before this change and maybe calls something different. |
Ah this change is just due to usages of HAVE_GNU_REGEX, but then, it has a fallback to POSIX regular expressions, so I suppose it should be fine? Not sure why it doesn't just always use regcomp... |
Ah the addresses shift due to usleep: I just checked, if I comment out the 2 Since we don't use the result of So the only meaningful change in functionality from this PR is the GNU vs POSIX regex above. Once that's clearified, this should be good to go. |
i have autoconf 2.71 on my buildsystem at least and would not mind this change, it seems to be a good cleanup |
FWIW I've already switched to _DEFAULT_SOURCE which should be compatible with older autoconf too, plus a bit more consistent across systems. Can you comment on the regex change above? Are both branches for POSIX and GNU regexes necessary? If not, then after this PR GNU regex branch is no-op and could be removed entirely. |
I do not see how just defining I just ran a libgphoto2 wants to run on multiple systems, Linux with glibc being a popular one, but certainly not the only one. There is Linux with non-glibc C libraries, there is FreeBSD and other BSDs, there is MacOS/OSX/whatevertheycallit, there is even Windows, and probably some system that does not come to mind right now. We tried to use mainly C standard conforming code where possible, and in a few places where it makes sense, we use system specific APIs or API extensions for which we may need to define some system specific preprocessor macros. I see the consistency argument, i.e. how having the same macro definitions in all source files can be useful to have the codebase behave the same in everywhere. So I do not understand how just defining
|
That's... a lot of questions about a small edit :) I'm happy to revert the Sounds like @msmeissn is okay with bumping autoconf version, and |
I'd still appreciate answers to my questions about regex stuff above though. I've already investigated all the differences as originally requested, and that's the only one that's left under question. |
Reverted; looks like I replaced it only in top-level configure.ac and missed the libgphoto2_port one when I did that change anyway. |
Remove Solaris __EXTENSIONS__ definition, which #include "config.h" will supply due to AC_USE_SYSTEM_EXTENSIONS.
In each compilation unit (with some exceptions like test programs), consistently have <empty line> #include "config.h" <empty line> after the first comment lines before including any standard library headers for which the config.h include file might contain feature test macros.
I just said we needed to discuss it, and Marcus responded: There is no need to bump the autoconf version from 2.69 to 2.71. Marcus wrote that he prepares the release tarball using autoconf 2.71, so the released tarballs contain the Oh and BTW, we used to have a camlib developer in the 2000s using a fairly old (at the time) system, and we started to be very conservative about build tool requirements to accommodate for their needs. These days though, it might be possible/reasonable to use slightly less ancient build tools these days. Not sure where to draw the border. And this is a topic to discuss a separate GitHub issue. We do not need to bump the requirements for this PR. |
Yepp, still on my to do list. |
That would be wonderful. Especially if it also means we can use various good stuff from C11 and later. But yeah, out of scope here. |
Just a quick update on what I have been doing, both to remind me of where I was when I continue, and to let you know that I am not just sitting on this.
|
Oh good catch! |
I would argue that the example programs in Also, I want to verify this PR has working OSX and mingw cross-compile builds before I merge this PR, and maybe even native Windows builds. This PR set out to improve the situation on e.g. OSX, and so it should not make it worse. |
The example/ programs are intended to be documentation, and therefore should build without libgphoto2's config.h file.
This is the only *.h file including config.h, that is why I missed this earlier.
As there is a non-GNU regex branch as well which does the same as the GNU regex branch, it makes no sense to maintain both.
Slightly cleaner alternative to #843, #615, #552 and others that ensures we always have those extension functions at autoconf level instead of having individual (and inconsistent)
#define
s in source files.