-
Notifications
You must be signed in to change notification settings - Fork 223
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
Modifications to get DocumentServer@core compiling and working under FreeBSD #297
base: develop
Are you sure you want to change the base?
Conversation
Explanations: OnlyOffice depends on v8 which needs specific compilation tools under FreeBSD (native v8 compilation tools are not written for FreeBSD. Thus under FreeBSD we use node10 available in the FreeBSD port compiled with the "shared" option. In that way libnode.so is used in order to get the v8 code). Since v8 library is got from FreeBSD ports, we also want to use the native ICU library, boost library, openssl library etc. Moreover it lets the sysadmin getting the latest security patches for these libraries and avoid security holes (without recompiling onlyoffice).
Correct an error in the code which leads to an error during compilation with clang.
Correct a syntax error in the code which leads to an error during compilation with clang. Add _gcvt function which does not exists under FreeBSD.
- Correct syntax error in the code which leads to error when compiling with clang (not casting signed 8-bits values greater than 0x80). - Add a specific code which finds the common working directory (using /proc for that purpose under FreeBSD is not possible)
Correct syntax error in the code which leads to an error with clang compiler: returning NULL (void*) to a variable which is unsigned int
@@ -77,13 +77,13 @@ namespace DocFileFormat | |||
} | |||
|
|||
StringTable( VirtualStreamReader *reader, int code_page_ ): | |||
code_page(code_page_), fExtend(false), cbData(0), cbExtra(0), DataExtra(NULL) | |||
code_page(code_page_), fExtend(false), cbData(0), cbExtra(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataExtra(0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the usefulness of this line since DataExtra is a std::vector which is well initialized without any specific constructor call.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked dev team and we think better variant is to define #define NULL 0
in #if
(not sure if translated that right, not good in C Programming)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would be very interested in having a good explaination about: what is the aim of this line and why using NULL rather than an integer?
Following the vector documentation constructors are:
explicit vector (const allocator_type& alloc = allocator_type());
explicit vector (size_type n, const value_type& val = value_type(), const allocator_type& alloc = allocator_type());
template <class InputIterator> vector (InputIterator first, InputIterator last,const allocator_type& alloc = allocator_type());
vector (const vector& x);
Since NULL might be assimilated by some compilers to 0 it seems this line is equivalent to DataExtra(0)
.
First, using DataExtra(0) or DataExtra() is equivalent following the documentation (default constructor: Constructs an empty container, with no elements.
).
Next, in C NULL refers to a pointer. That's why I don't understand why using it in that precise case?
Or maybe I missed something but from my point of view this explicit constructor call is just useless (and syntaxically wrong).
Last but not least redefining NULL to 0 might not be a good idea since cast checks would be wrong
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked our dev @ElenaSubbotina about this part and this may be some leftover from early days
We need some time to figure out if this code really needed in that form and could changes break something else, but currently we have not enought resource, since we are planning to release next major update soon and all work in there
I hope we'll have time to look into it again after major release
Thank you for you job
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok I understand. I hope you'll have time soon. I also hope most of the update (in particular all the preproc conditions and specific code surrounded by FreeBSD preproc conditions) would be added in the next major release.
Maybe you can surround this declaration with #ifdef (and all the code updates you didn't checked yet) in order to have the next major release compiling under FreeBSD (from my point of view, I'm not asking you to try to compile each release under FreeBSD but at least keep patches for that purpose in the master repository).
As you may see some people want/wait/need that feature.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also hope most of the update (in particular all the preproc conditions and specific code surrounded by FreeBSD preproc conditions) would be added in the next major release.
Sorry, I don't think we can do that in next release
I'm sure that in 99% of those statements are correct and will good, but core
is our base project and any major redone will require a lot of testing from QA and we do not have time for this in our release schedule
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even with preproc conditions ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
even with preproc conditions ?
Sorry, no
New release in final stage of testing and we are not 100% this changes will not cause any side-effects and we miss our deadlines if there will be sideeffects
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok. So I hope it will be added as soon as possible.
{ | ||
parse( reader, (unsigned int)reader->GetPosition(), 0, false ); | ||
} | ||
|
||
StringTable( POLE::Stream* tableStream, unsigned int fc, unsigned int lcb, int nWordVersion, bool bReadExta = false) : | ||
code_page(1250), fExtend(false), cbData(0), cbExtra(0), DataExtra(NULL) | ||
code_page(1250), fExtend(false), cbData(0), cbExtra(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DataExtra(0)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand the usefulness of this line since DataExtra is a std::vector which is well initialized without any specific constructor call.
|
||
memset(buf, 0, NS_FILE_MAX_PATH); | ||
if (sysctl(mib, 4, &buf, &size, NULL, 0) != 0) { | ||
size = readlink("/proc/curproc/file", buf, size - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/proc is not mounted by default, not sure it's worth keeping it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can have /proc mounted. sysctl might be enough for most of the cases but if not (I don't know in which case it wouldn't work..) you could still mount /proc and keep that code working
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you want, I never saw a sysctl failing and if it's the case you're probably doomed somehow.
@@ -40,6 +44,18 @@ else | |||
PACKAGE_VERSION := $(PRODUCT_VERSION)-$(BUILD_NUMBER) | |||
ARCH_REPO_DIR := linux | |||
endif | |||
ifeq ($(UNAME_S),FreeBSD) | |||
PLATFORM := linux |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not PLATFORM := freebsd ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it would be great to use "PLATFORM := freebsd" but all the compilation files would need to be changed without any improvments on the results. Since it changes nothing i prefered keep it like that. It needs few changes and everything is fine!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
which files? It seems to only be used in the Makefile and seems useless.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you're right: in particular in Makefiles and QMake files too.
For the moment I prefer minimizing updates. When Makefiles will be removed we (you?) will be able to do more proper things.
@@ -48,6 +48,11 @@ char* gcvt(double x, int n, char* b) | |||
#define _gcvt gcvt | |||
#endif | |||
|
|||
#ifdef __FreeBSD__ | |||
#define _gcvt(x,n,b) sprintf(b, "%.17g", x) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Android uses:
char* gcvt(double x, int n, char* b) {
sprintf(b, "%.*g", n, x);
return b;
}
X2
see XtConverter/build/Android/libx2t/src/main/cpp/workaround/gcvt/gcvt.c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's nearly the same result..
#ifdef __FreeBSD__ | ||
#define _gcvt(x,n,b) sprintf(b, "%.17g", x) | ||
#endif | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whitespace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what do you mean?
extra blank line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there's more than a blank line.. I hope it's not the most important thing of this patch..
Should we really care about that?
Well, thats a lot of changes, I'm not sure that dev team will have a lot of time to review it |
@@ -77,13 +77,13 @@ namespace DocFileFormat | |||
} | |||
|
|||
StringTable( VirtualStreamReader *reader, int code_page_ ): | |||
code_page(code_page_), fExtend(false), cbData(0), cbExtra(0), DataExtra(NULL) | |||
code_page(code_page_), fExtend(false), cbData(0), cbExtra(0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked dev team and we think better variant is to define #define NULL 0
in #if
(not sure if translated that right, not good in C Programming)
We are planning to backport your changes in our code manually, with careful testing, since we fear some of this changes can broke some other OS variants (please do not forget, that this code not only used on Linux, but also on Mac, iOS and Android) |
Hi @ShockwaveNN BSD users will be greatfull :) |
@sankayop Sorry, I cannot promise anything, since I'm only a QA, but our dev team promise me this:#297 (comment) |
Thanks, still struggling to get it right so that's why I'm interested :) |
As I understand some of this changes may broke compatibility with some prehistoric OSes like WinXP which we support (some of our paid clients using it) and may broke Android\iOS But this is how it's told to me, I'm not good at cpp code |
Since there is preprocessor conditions everywhere for FreeBSD code it won't break something ;) |
Here is a patch in order to get the core package of DocumentServer compiling and working under FreeBSD.
Most of the patch is adding "FreeBSD" to the list of "Linux" preproc conditions.
2-3 lines of code (mainly errors or cast problem) have been updated due to errors with clang compiler (the one used under FreeBSD). It does not changes something for other platforms.
Last the Linux code used to get the common working directory is not working under FreeBSD. Thus a specific one has been added.