Skip to content

Commit caa3d74

Browse files
committed
Fix plugin loading issues on older DragonFly BSD
1 parent c3e55c7 commit caa3d74

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

Makefile.PL

+11-8
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,7 @@ my $static = 0;
633633
my $reported = 0;
634634

635635
sub compile_lib {
636-
my ($lib, $mm, $name) = @_;
636+
my ($lib, $mm, $name, $isPlugin) = @_;
637637
my @args = (
638638
'$(LD) $(OPTIMIZE) -lstdc++ -shared', "-o ${name}",
639639
);
@@ -646,10 +646,13 @@ sub compile_lib {
646646
push @args, '-Wl,--major-image-version,0.0.9';
647647
push @args, '-Wl,--minor-image-version,0.0.9';
648648
}
649-
# add explicit path to libsass lib
650-
# needed to resolve lib from plugins
649+
# add explicit relative path to resolve libsass library
650+
# makes plugin.so look for -lsass in `../..` when loaded
651+
# this may not be supported on all operating systems!
651652
unless ($^O eq 'MSWin32' && $Config{cc} =~ /^cl/) {
652-
push @args, '-Wl,-rpath,\\$$ORIGIN/../..';
653+
# the `-z origin` seems needed for some BSD derivates!
654+
push @args, '-Wl,-z,origin' if $isPlugin && $^O ne 'MSWin32';
655+
push @args, '-Wl,-rpath,\\$$ORIGIN/../..' if $isPlugin;
653656
}
654657
# add explicit library name on OSX
655658
if ($^O eq 'darwin') {
@@ -722,7 +725,7 @@ sub libsass_plugin_math
722725
# make sure the plugin path exists for output
723726
push @ret, "\t" . '$(MKPATH) $(INST_ARCHAUTODIR)/plugins/math';
724727
# create the libsass shared library by linking against all objects
725-
push @ret, "\t" . compile_lib('math.$(SO)', $_[0], '$(MATH_LIB)') . ' $(MATH_OBJ)'
728+
push @ret, "\t" . compile_lib('math.$(SO)', $_[0], '$(MATH_LIB)', 1) . ' $(MATH_OBJ)'
726729
. ' ' . ($static ? '$(LIBSASS_OBJ)' : '-L$(INST_ARCHAUTODIR) -lsass -lstdc++');
727730
# change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
728731
push @ret, "\t" . 'install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
@@ -745,7 +748,7 @@ sub libsass_plugin_img_size
745748
# make sure the plugin path exists for output
746749
push @ret, "\t" . '$(MKPATH) $(INST_ARCHAUTODIR)/plugins/img-size';
747750
# create the libsass shared library by linking against all objects
748-
push @ret, "\t" . compile_lib('img-size.$(SO)', $_[0], '$(IMG_SIZE_LIB)') . ' $(IMG_SIZE_OBJ)'
751+
push @ret, "\t" . compile_lib('img-size.$(SO)', $_[0], '$(IMG_SIZE_LIB)', 1) . ' $(IMG_SIZE_OBJ)'
749752
. ' ' . ($static ? '$(LIBSASS_OBJ)' : '-L$(INST_ARCHAUTODIR) -lsass -lstdc++');
750753
# change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
751754
push @ret, "\t" . 'install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
@@ -773,7 +776,7 @@ sub libsass_plugin_digest
773776
# make sure the plugin path exists for output
774777
push @ret, "\t" . '$(MKPATH) $(INST_ARCHAUTODIR)/plugins/digest';
775778
# create the libsass shared library by linking against all objects
776-
push @ret, "\t" . compile_lib('digest.$(SO)', $_[0], '$(DIGEST_LIB)') . ' $(DIGEST_OBJ)'
779+
push @ret, "\t" . compile_lib('digest.$(SO)', $_[0], '$(DIGEST_LIB)', 1) . ' $(DIGEST_OBJ)'
777780
. ' ' . ($static ? '$(LIBSASS_OBJ)' : '-L$(INST_ARCHAUTODIR) -lsass -lstdc++');
778781
# change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
779782
push @ret, "\t" . 'install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'
@@ -801,7 +804,7 @@ sub libsass_plugin_glob
801804
# make sure the plugin path exists for output
802805
push @ret, "\t" . '$(MKPATH) $(INST_ARCHAUTODIR)/plugins/glob';
803806
# create the libsass shared library by linking against all objects
804-
push @ret, "\t" . compile_lib('glob.$(SO)', $_[0], '$(GLOB_LIB)') . ' $(GLOB_OBJ)'
807+
push @ret, "\t" . compile_lib('glob.$(SO)', $_[0], '$(GLOB_LIB)', 1) . ' $(GLOB_OBJ)'
805808
. ' ' . ($static ? '$(LIBSASS_OBJ)' : '-L$(INST_ARCHAUTODIR) -lsass -lstdc++');
806809
# change dynamic loading of libsass.dylib to look relative to ourself (only on mac)
807810
push @ret, "\t" . 'install_name_tool -change libsass.dylib @loader_path/../../libsass.dylib'

0 commit comments

Comments
 (0)